Example #1
0
 /**
  * Delete a content page from the database.
  *
  * @param bool $deleteChildren Set to true if the method should also delete
  * children pages.
  * @access public
  * @return void
  */
 public function deleteContent($deleteChildren = true)
 {
     if ($this->id == 0) {
         return false;
     }
     // If the page children must also be removed, let the page tree class
     // handle content delete action.
     if ($deleteChildren == true) {
         $tree = new PageTree();
         return $tree->removePage($this->id);
     }
     $innomaticContainer = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     if ($this->domainDa->execute("DELETE FROM innomedia_pages WHERE id={$this->id}")) {
         $this->domainDa->execute("DELETE FROM innomedia_blocks WHERE pageid={$this->id}");
         // @TODO: convert the following code in the code with the use of hook
         // Start - code for delete element of menu ordering
         $app_deps = new \Innomatic\Application\ApplicationDependencies($innomaticContainer->getDataAccess());
         if ($app_deps->isInstalled('innomedia-menu-editor') && $app_deps->isEnabled('innomedia-menu-editor', $innomaticContainer->getCurrentTenant()->getDomainId())) {
             //delete element from secondary menu ordering
             $editorMenu = new \Innomedia\Menu\Editor\Menu(DesktopFrontController::instance('\\Innomatic\\Desktop\\Controller\\DesktopFrontController')->session, null, 'menu/includemenu');
             $editorMenu->removeElementFromMenuByPageID($this->id);
         }
         // End - code for delete element of menu ordering
         $this->id = 0;
         return true;
     } else {
         return false;
     }
 }
function main_applicationversions($eventData)
{
    global $gLocale, $gXmlDefinition, $gPageTitle, $gToolbars;
    $acRemote = new \Innomatic\Application\AppCentralRemoteServer($eventData['id']);
    $availReps = $acRemote->ListAvailableRepositories(isset($eventData['refresh']) ? true : false);
    $availMods = $acRemote->ListAvailableApplications($eventData['repid'], isset($eventData['refresh']) ? true : false);
    $appVersions = $acRemote->ListAvailableApplicationVersions($eventData['repid'], $eventData['applicationid'], isset($eventData['refresh']) ? true : false);
    $xAccount = new WebServicesAccount($acRemote->mAccountId);
    $headers[0]['label'] = $gLocale->getStr('version.header');
    $headers[1]['label'] = $gLocale->getStr('dependencies.header');
    $headers[2]['label'] = $gLocale->getStr('installed_version.header');
    $gXmlDefinition = '<vertgroup><name>applications</name>
  <children>
    <label><name>title</name>
      <args>
        <bold>true</bold>
        <label type="encoded">' . urlencode($xAccount->mName . ' - ' . $availReps[$eventData['repid']]['name'] . ' - ' . $availMods[$eventData['applicationid']]['appid']) . '</label>
      </args>
    </label>
    <table><name>applications</name>
      <args>
        <headers type="array">' . WuiXml::encode($headers) . '</headers>
        <rowsperpage>10</rowsperpage>
        <pagesactionfunction>repapplications_list_action_builder</pagesactionfunction>
        <pagenumber>' . (isset($eventData['pagenumber']) ? $eventData['pagenumber'] : '') . '</pagenumber>
        <sessionobjectusername>' . $eventData['id'] . '-' . $eventData['repid'] . '-' . $eventData['applicationid'] . '</sessionobjectusername>
      </args>
      <children>';
    $row = 0;
    $appQuery = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->execute('SELECT appversion ' . 'FROM applications ' . 'WHERE appid=' . \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->formatText($availMods[$eventData['applicationid']]['appid']));
    while (list($version, $data) = each($appVersions)) {
        if (strlen($data['dependencies'])) {
            $appDeps = new \Innomatic\Application\ApplicationDependencies();
            $depCheck = $appDeps->checkApplicationDependencies(0, '', $appDeps->explodeDependencies($data['dependencies']));
        } else {
            $depCheck = false;
        }
        if ($appQuery->getNumberRows()) {
            $currentVersion = $appQuery->getFields('appversion');
        } else {
            $currentVersion = $gLocale->getStr('none_version.label');
        }
        if ($depCheck == false) {
            $appInstallable = true;
            $missingDeps = '';
            if ($appQuery->getNumberRows()) {
                switch (\Innomatic\Application\ApplicationDependencies::compareVersionNumbers($version, $currentVersion)) {
                    case \Innomatic\Application\ApplicationDependencies::VERSIONCOMPARE_EQUAL:
                        $label = $gLocale->getStr('reinstall_application.button');
                        $icon = 'cycle';
                        break;
                    case \Innomatic\Application\ApplicationDependencies::VERSIONCOMPARE_MORE:
                        $label = $gLocale->getStr('update_application.button');
                        $icon = 'up';
                        break;
                    case \Innomatic\Application\ApplicationDependencies::VERSIONCOMPARE_LESS:
                        $label = $gLocale->getStr('downgrade_application.button');
                        $icon = 'down';
                        break;
                }
            } else {
                $label = $gLocale->getStr('install_application.button');
                $icon = 'folder';
            }
        } else {
            $appInstallable = false;
            $missingDeps = '<br><strong>' . $gLocale->getStr('missing_deps.label') . '</strong>';
            while (list(, $dep) = each($depCheck)) {
                $missingDeps .= '<br>' . $dep;
            }
        }
        $toolbars = '';
        if ($appInstallable) {
            $toolbars .= '<button>
                    <args>
              <label>' . WuiXml::cdata($label) . '</label>
        <themeimage>' . $icon . '</themeimage>
        <horiz>true</horiz>
        <action>' . WuiXml::cdata(\Innomatic\Wui\Dispatch\WuiEventsCall::buildEventsCallString('', array(array('view', 'repositoryapplications', array('id' => $eventData['id'], 'repid' => $eventData['repid'])), array('action', 'installapplication', array('id' => $eventData['id'], 'repid' => $eventData['repid'], 'applicationid' => $eventData['applicationid'], 'version' => $version))))) . '</action>
                  </args>
                </button>';
        }
        $gXmlDefinition .= '<label row="' . $row . '" col="0"><name>version</name>
  <args>
    <label type="encoded">' . urlencode($version) . '</label>
  </args>
</label>

<label row="' . $row . '" col="1"><name>dependencies</name>
  <args>
    <label type="encoded">' . urlencode(str_replace(',', '<br>', $data['dependencies']) . (strlen($data['suggestions']) ? '<br><br><strong>' . $gLocale->getStr('suggestions.label') . '</strong><br>' . str_replace(',', '<br>', $data['suggestions']) . '<br>' : '') . $missingDeps) . '</label>
  </args>
</label>

<label row="' . $row . '" col="2"><name>current</name>
  <args>
    <label type="encoded">' . urlencode($currentVersion) . '</label>
  </args>
</label>

<horizgroup row="' . $row . '" col="3"><name>tb</name>
    <children>' . $toolbars . '</children>
</horizgroup>';
        $row++;
    }
    $gXmlDefinition .= '      </children>
    </table>
  </children>
</vertgroup>';
    $gToolbars['reptools'] = array('refresh' => array('label' => $gLocale->getStr('refresh.button'), 'themeimage' => 'cycle', 'horiz' => 'true', 'action' => \Innomatic\Wui\Dispatch\WuiEventsCall::buildEventsCallString('', array(array('view', 'applicationversions', array('id' => $eventData['id'], 'repid' => $eventData['repid'], 'applicationid' => $eventData['applicationid'], 'refresh' => '1'))))));
    $gPageTitle .= ' - ' . $gLocale->getStr('applicationversions.title');
}
 public function viewsituation($eventData)
 {
     $domainsQuery = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->execute('SELECT domainid FROM domains ORDER BY domainid');
     $applicationsQuery = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->execute('SELECT appid FROM applications WHERE onlyextension=' . \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->formatText(\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->fmtfalse) . ' ORDER BY appid');
     $headers = array();
     $cont = 1;
     while (!$applicationsQuery->eof) {
         $origLabel = $applicationsQuery->getFields('appid');
         $label = '';
         for ($i = 0; $i < strlen($origLabel); $i++) {
             if ($i) {
                 $label .= '<br>';
             }
             $label .= $origLabel[$i];
         }
         $headers[$cont++]['label'] = $label;
         $applicationsQuery->moveNext();
     }
     $xmlDef = '<table><name>situation</name>
   <args>
     <headers type="array">' . WuiXml::encode($headers) . '</headers>
   </args>
   <children>';
     $row = 0;
     $appDeps = new \Innomatic\Application\ApplicationDependencies();
     while (!$domainsQuery->eof) {
         $xmlDef .= '<label row="' . $row . '" col="0">
       <args>
         <label type="encoded">' . urlencode($domainsQuery->getFields('domainid')) . '</label>
         <compact>true</compact>
       </args>
     </label>';
         $col = 1;
         $applicationsQuery->MoveFirst();
         while (!$applicationsQuery->eof) {
             $enabled = $appDeps->IsEnabled($applicationsQuery->getFields('appid'), $domainsQuery->getFields('domainid'));
             $xmlDef .= '<image row="' . $row . '" col="' . $col . '" halign="center" valign="middle">
           <args>
             <imageurl>' . ($enabled ? $this->wuiMainframe->mThemeHandler->mStyle['greenball'] : $this->wuiMainframe->mThemeHandler->mStyle['redball']) . '</imageurl>
           </args>
         </image>';
             $col++;
             $applicationsQuery->moveNext();
         }
         $row++;
         $domainsQuery->moveNext();
     }
     $xmlDef .= '  </children>
 </table>';
     $this->wuiMainframe->addChild(new WuiXml('', array('definition' => $xmlDef)));
 }