예제 #1
0
 /**
  * Funkce pro editaci formátu
  */
 function newFormat()
 {
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'bkef.php';
     $model = new BkefModel();
     if ($_POST['potvrzeni'] == 'new') {
         //skutecne smazeme
         $xml = $model->load(JRequest::getInt('article'));
         $maId = intval(JRequest::getInt('maId', -1));
         $fId = intval(JRequest::getInt('fId', -1));
         if (!isset($xml->MetaAttributes[0]->MetaAttribute[$maId]->Formats[0])) {
             $xml->MetaAttributes[0]->MetaAttribute[$maId]->addChild('Formats');
         }
         /*projdeme formaty a najdeme vsechna jmena*/
         $name = (string) JRequest::getString('name');
         if (count($xml->MetaAttributes[0]->MetaAttribute[$maId]->Formats[0]->Format) > 0) {
             $namesArr = array();
             foreach ($xml->MetaAttributes[0]->MetaAttribute[$maId]->Formats[0]->Format as $format) {
                 $namesArr[] = (string) $format['name'];
             }
             while (in_array($name, $namesArr)) {
                 $name = $name . 'X';
             }
         }
         /**/
         $format = $xml->MetaAttributes[0]->MetaAttribute[$maId]->Formats[0]->addChild('Format');
         $format['name'] = $name;
         $format->Author = JRequest::getString('author');
         $format->DataType = JRequest::getString('dataType');
         $format->ValueType = JRequest::getString('valueType');
         $model->save(JRequest::getInt('article'), $xml->asXML());
         $this->_redirect = 'index.php?option=com_bkef&task=metaAttribute&article=' . JRequest::getInt('article') . '&maId=' . $maId;
     } else {
         //zobrazime dotaz
         require_once JPATH_COMPONENT . DS . 'views' . DS . 'iframe' . DS . 'editFormat.html.php';
         $view = new BkefViewEditFormat();
         $view->xml = $model->load(JRequest::getInt('article'));
         $view->articleTitle = $model->loadTitle(JRequest::getInt('article'));
         $view->h1 = JText::_("NEW_FORMAT");
         $view->potvrzeni = 'new';
         $view->article = JRequest::getInt('article');
         $view->maId = JRequest::getInt('maId');
         $view->fId = -1;
         $view->display();
     }
 }
예제 #2
0
 /**
  * Funkce pro editaci formátu
  */
 function editFormat()
 {
     /*DONE_X*/
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'bkef.php';
     $model = new BkefModel();
     if ($_POST['potvrzeni'] == 'edit') {
         //skutecne smazeme
         $xml = $model->load(JRequest::getInt('article'));
         $maId = intval(JRequest::getInt('maId', -1));
         $fId = intval(JRequest::getInt('fId', -1));
         /*projdeme formaty a najdeme vsechna jmena*/
         $name = (string) JRequest::getString('name');
         if (count($xml->MetaAttributes[0]->MetaAttribute[$maId]->Formats[0]->Format) > 0) {
             $namesArr = array();
             $fIdX = 0;
             foreach ($xml->MetaAttributes[0]->MetaAttribute[$maId]->Formats[0]->Format as $format) {
                 if ($fId != $fIdX) {
                     $namesArr[] = (string) $format->Name[0];
                 }
                 $fIdX++;
             }
             while (in_array($name, $namesArr)) {
                 $name = $name . 'X';
             }
         }
         /**/
         $format = $xml->MetaAttributes[0]->MetaAttribute[$maId]->Formats[0]->Format[$fId];
         $format->Name = $name;
         $format->DataType = JRequest::getString('dataType');
         $format->ValueType = JRequest::getString('valueType');
         //informace o datu/čase poslední změny
         $author = $this->getUserName();
         $xml->Header[0]->LastModified[0]->Timestamp = date('c');
         $xml->Header[0]->LastModified[0]->Author = $author;
         $xml->MetaAttributes[0]->MetaAttribute[$maId]->LastModified[0]->Timestamp = date('c');
         $xml->MetaAttributes[0]->MetaAttribute[$maId]->LastModified[0]->Author = $author;
         $format->LastModified[0]->Timestamp = date('c');
         $format->LastModified[0]->Author = $author;
         //save
         $model->save(JRequest::getInt('article'), $xml->asXML());
         $this->_redirect = 'index.php?option=com_bkef&task=format&article=' . JRequest::getInt('article') . '&maId=' . $maId . '&fId=' . $fId;
     } else {
         //zobrazime dotaz
         require_once JPATH_COMPONENT . DS . 'views' . DS . 'iframe' . DS . 'editFormat.html.php';
         $view = new BkefViewEditFormat();
         $view->xml = $model->load(JRequest::getInt('article'));
         $view->articleTitle = $model->loadTitle(JRequest::getInt('article'));
         $view->h1 = JText::_('FORMAT_EDITATION');
         $view->potvrzeni = 'edit';
         $view->article = JRequest::getInt('article');
         $view->maId = JRequest::getInt('maId');
         $view->fId = JRequest::getInt('fId', -1);
         $view->display();
     }
 }