Example #1
0
 /**
  * Funkce pro editaci metaatrbutu
  */
 function newGroupMetaAttribute()
 {
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'bkef.php';
     $model = new BkefModel();
     if ($_POST['potvrzeni'] == 'new') {
         //skutecne smazeme
         $xml = $model->load(JRequest::getInt('article'));
         $ma = $xml->MetaAttributes[0]->addChild('MetaAttribute');
         /*projdeme metaatributy a najdeme vsechna jmena a id*/
         $name = (string) JRequest::getString('name');
         $id = 0;
         if (count($xml->MetaAttributes[0]->MetaAttribute) > 0) {
             $namesArr = array();
             foreach ($xml->MetaAttributes[0]->MetaAttribute as $metaAttribute) {
                 $namesArr[] = (string) $metaAttribute['name'];
                 $mId = intval($metaAttribute['id']);
                 if ($mId > $id) {
                     $id = $mId;
                 }
             }
             $id++;
             while (in_array($name, $namesArr)) {
                 $name = $name . 'X';
             }
         } else {
             $id = 1;
         }
         /**/
         $ma['name'] = $name;
         $ma['id'] = $id;
         $ma['level'] = '1';
         $ma->Variability = JRequest::getString('variability');
         $ma->Annotation->Text = JRequest::getString('annotation');
         $ma->Annotation->Author = JRequest::getString('annotationAuthor');
         $model->save(JRequest::getInt('article'), $xml->asXML());
         $this->_redirect = 'index.php?option=com_bkef&task=selArticle&article=' . JRequest::getInt('article');
     } else {
         //zobrazime dotaz
         require_once JPATH_COMPONENT . DS . 'views' . DS . 'iframe' . DS . 'editGroupMetaAttribute.html.php';
         $view = new BkefViewEditMetaAttribute();
         $view->xml = $model->load(JRequest::getInt('article'));
         $view->h1 = JText::_('NEW_GROUP_META');
         $view->potvrzeni = 'new';
         $view->maId = -1;
         $view->article = JRequest::getInt('article');
         $view->display();
     }
 }
Example #2
0
 /**
  * Funkce pro editaci metaatrbutu
  */
 function editGroupMetaAttribute()
 {
     /*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));
         $metaAttribute = $xml->MetaAttributes[0]->MetaAttribute[$maId];
         $metaAttribute->Variability = JRequest::getString('variability');
         $metaAttribute->LastModified[0]->Timestamp = date('c');
         $metaAttribute->LastModified[0]->Author = $this->getUserName();
         $xml->Header[0]->LastModified[0]->Author = $this->getUserName();
         $xml->Header[0]->LastModified[0]->Timestamp = date('c');
         /*projdeme metaatributy a najdeme vsechna jmena*/
         $name = (string) JRequest::getString('name');
         $namesArr = array();
         $maIdX = 0;
         foreach ($xml->MetaAttributes[0]->MetaAttribute as $metaAttribute) {
             if ($maIdX != $maId) {
                 $namesArr[] = (string) $metaAttribute['name'];
             }
             $maIdX++;
         }
         while (in_array($name, $namesArr)) {
             $name = $name . 'X';
         }
         /**/
         $xml->MetaAttributes[0]->MetaAttribute[$maId]['name'] = $name;
         $model->save(JRequest::getInt('article'), $xml->asXML());
         $this->_redirect = 'index.php?option=com_bkef&task=groupMetaAttribute&article=' . JRequest::getInt('article') . '&maId=' . $maId . '#basicInfo';
     } else {
         //zobrazime dotaz
         require_once JPATH_COMPONENT . DS . 'views' . DS . 'iframe' . DS . 'editGroupMetaAttribute.html.php';
         $view = new BkefViewEditMetaAttribute();
         $view->xml = $model->load(JRequest::getInt('article'));
         $view->h1 = JText::_('EDIT_GROUP_META');
         $view->potvrzeni = 'edit';
         $view->article = JRequest::getInt('article');
         $view->maId = JRequest::getInt('maId');
         $view->display();
     }
 }