コード例 #1
0
ファイル: 12ImportCsvData.php プロジェクト: GruppoMeta/Movio
 function execute()
 {
     if (__Request::get('mbModuleType') == 'csv') {
         $tableName = $this->parent->getTableName();
         $fields = __Request::get('fieldName');
         $modelName = 'userModules.' . $tableName . '.models.Model';
         $fieldsMap = array();
         foreach ($fields as $f) {
             $col = str_replace('row_', '', $f);
             $fieldsMap[] = array($f, $col);
         }
         $ar = org_glizy_ObjectFactory::createModel($modelName);
         $csvIterator = org_glizy_ObjectFactory::createObject('movio.modules.modulesBuilder.services.CVSImporter', __Request::get('mbCsvOptions'));
         foreach ($csvIterator as $row) {
             if ($f) {
                 $ar->emptyRecord();
                 foreach ($fieldsMap as $f) {
                     $ar->{$f[0]} = $row->{$f[1]};
                 }
                 $ar->publish();
             }
         }
     }
     return true;
 }
コード例 #2
0
ファイル: RecordIterator.php プロジェクト: GruppoMeta/Movio
 function &current()
 {
     $fields = $this->_rs->fields;
     $activeRecord =& org_glizy_ObjectFactory::createModel($this->_recordClassName);
     $activeRecord->loadFromArray($fields);
     return $activeRecord;
 }
コード例 #3
0
ファイル: Module.php プロジェクト: GruppoMeta/Movio
 function createChildComponents()
 {
     $entityTypeService = $this->_application->retrieveProxy('movio.modules.ontologybuilder.service.EntityTypeService');
     $properties = $entityTypeService->getEntityTypeAttributeProperties(__Request::get('entityTypeId'), $this->_parent->getId());
     $moduleId = $properties['entity_properties_params'];
     $this->_content['title'] = $this->data->text;
     $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Text', $this->_application, $this, 'glz:Text', 'title', 'title');
     $this->addChild($c);
     $this->_content['url'] = __Routing::makeUrl($moduleId, array('document_id' => $this->data->id, 'title' => $this->data->text));
     $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Text', $this->_application, $this, 'glz:Text', 'url', 'url');
     $this->addChild($c);
     $module = org_glizy_Modules::getModule($moduleId);
     $ar = org_glizy_ObjectFactory::createModel($module->classPath . '.models.Model');
     $ar->load($this->data->id);
     if ($ar->fieldExists('image')) {
         $this->_content['__image'] = $ar->image;
         $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Image', $this->_application, $this, 'glz:Image', '__image', '__image');
         $c->setAttribute('width', __Config::get('THUMB_WIDTH'));
         $c->setAttribute('height', __Config::get('THUMB_HEIGHT'));
         $c->setAttribute('crop', true);
         $this->addChild($c);
     } else {
         $c =& org_glizy_ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.NoImage', $this->_application, $this, 'glz:Image', '__image', '__image');
         $c->setAttribute('width', __Config::get('THUMB_SMALL_WIDTH'));
         $c->setAttribute('height', __Config::get('THUMB_SMALL_HEIGHT'));
         $this->addChild($c);
     }
 }
コード例 #4
0
ファイル: Modify.php プロジェクト: GruppoMeta/Movio
 public function executeLater()
 {
     if ($this->user->isLogged() && $this->submit && $this->controller->validate()) {
         $ar = org_glizy_ObjectFactory::createModel('org.glizy.models.User');
         $ar->load($this->user->id);
         $email = org_glizy_Request::get('user_email', '');
         if ($email != $ar->user_loginId) {
             $ar2 = org_glizy_ObjectFactory::createModel('org.glizy.models.User');
             if ($ar2->find(array('user_loginId' => $email)) && $ar2->user_id != $ar->user_id) {
                 $this->view->validateAddError('L\'email è già presente nel database, usare un\'altra email');
                 return;
             }
         }
         // TODO migliorare così siamo esposti a problemi di sicurezza
         $fields = $ar->getFields();
         foreach ($fields as $k => $v) {
             if ($k == 'user_password') {
                 continue;
             }
             if (__Request::exists($k)) {
                 $ar->{$k} = __Request::get($k);
             }
         }
         $password = __Request::get('user_password');
         if ($password) {
             $ar->user_password = glz_password($password);
         }
         $ar->user_loginId = $email;
         $ar->user_email = $email;
         $ar->save();
         $this->changeAction('modifyConfirm');
     }
 }
コード例 #5
0
ファイル: Registration.php プロジェクト: GruppoMeta/Movio
 public function executeLater()
 {
     if ($this->submit && $this->controller->validate()) {
         $email = org_glizy_Request::get('user_email', '');
         $ar = org_glizy_ObjectFactory::createModel('org.glizy.models.User');
         if ($ar->find(array('user_loginId' => $email))) {
             // TODO tradurre
             $this->view->validateAddError('L\'email è già presente nel database, usare un\'altra email o richiedere la password');
             return;
         }
         $fields = $ar->getFields();
         foreach ($fields as $k => $v) {
             if (__Request::exists($k)) {
                 $ar->{$k} = __Request::get($k);
             }
         }
         $ar->user_FK_usergroup_id = __Config::get('USER_DEFAULT_USERGROUP');
         $ar->user_isActive = __Config::get('USER_DEFAULT_ACTIVE_STATE');
         $ar->user_password = glz_password(__Request::get('user_password'));
         $ar->user_loginId = $email;
         $ar->user_email = $email;
         $ar->user_dateCreation = new org_glizy_types_DateTime();
         $ar->save();
         $this->changeAction('registrationConfirm');
     }
 }
コード例 #6
0
ファイル: Edit.php プロジェクト: GruppoMeta/Movio
 public function execute()
 {
     $id = __Request::get('id');
     $media = org_glizy_ObjectFactory::createModel('org.glizycms.models.Media');
     $media->load($id);
     $data = $media->getValuesAsArray();
     $this->view->setData($data);
 }
コード例 #7
0
ファイル: DB.php プロジェクト: GruppoMeta/Movio
 function __construct($options = array(), $level = GLZ_LOG_DEBUG, $group = '')
 {
     parent::__construct($options, $level, $group);
     $this->_ar = org_glizy_ObjectFactory::createModel('org.glizy.models.Log');
     $this->application = org_glizy_ObjectValues::get('org.glizy', 'application');
     // TODO
     //$this->_ar->enableQueue();
 }
コード例 #8
0
ファイル: AdminApplication.php プロジェクト: GruppoMeta/Movio
 function switchEditingLanguage($id)
 {
     $ar = org_glizy_ObjectFactory::createModel('org.glizycms.core.models.Language');
     $ar->load($id);
     org_glizy_Session::set('glizy.editingLanguage', $ar->language_code);
     org_glizy_Session::set('glizy.editingLanguageId', $ar->language_id);
     org_glizy_Session::set('glizy.editingLanguageIsDefault', $ar->language_isDefault);
     org_glizy_ObjectValues::set('org.glizy', 'editingLanguageId', $ar->language_id);
 }
コード例 #9
0
ファイル: Delete.php プロジェクト: GruppoMeta/Movio
 function execute()
 {
     if ($this->id > 0) {
         $this->logAndMessage(__T('Record cancellato'));
         $ar = org_glizy_ObjectFactory::createModel($this->modelName);
         $ar->delete($this->id);
         $this->changePage('link', array('pageId' => $this->pageId));
     }
 }
コード例 #10
0
ファイル: GetRecord.php プロジェクト: GruppoMeta/Movio
 protected function loadeRecord($id)
 {
     $this->arPico = org_glizy_ObjectFactory::createModel('org.glizy.oaipmh.models.PicoQueue');
     if ($this->arPico->find(array('picoqueue_identifier' => $id))) {
         // record trovato
         $this->setClass = org_glizy_ObjectFactory::createObject($this->arPico->picoqueue_recordModule, $this->_application);
     } else {
         $this->arPico = null;
     }
 }
コード例 #11
0
ファイル: RelationHasMany.php プロジェクト: GruppoMeta/Movio
 function create($params)
 {
     $this->_reset();
     $this->record =& org_glizy_ObjectFactory::createModel($this->_className);
     $this->record->setProcessRelations(false);
     if (count($params)) {
         $this->record->loadFromArray($params);
     }
     $this->_bindRecordFields();
 }
コード例 #12
0
ファイル: Add.php プロジェクト: GruppoMeta/Movio
 function executeLater()
 {
     if ($this->submit) {
         if ($this->controller->validate()) {
             $isNewRecord = $this->id == 0;
             $ar = org_glizy_ObjectFactory::createModel($this->modelName);
             $ar->loadFromArray(__Request::getAllAsArray());
             $this->id = $ar->save();
             $this->redirect($isNewRecord);
         }
     }
 }
コード例 #13
0
ファイル: MediaManager.php プロジェクト: GruppoMeta/Movio
 /**
  * @param $id
  *
  * @return GlizyObject|null
  */
 static function &getMediaById($id)
 {
     $ar = org_glizy_ObjectFactory::createModel('org.glizycms.models.Media');
     if ($ar->load($id)) {
         $media =& org_glizycms_mediaArchive_MediaManager::getMediaByRecord($ar);
         return $media;
     } else {
         // TODO
         // ERRORE
     }
     return NULL;
 }
コード例 #14
0
ファイル: Registry.php プロジェクト: GruppoMeta/Movio
 static function remove($path)
 {
     $params =& org_glizy_Registry::_getValuesArray();
     if (array_key_exists($path, $params)) {
         unset($params[$path]);
     }
     $rs = org_glizy_ObjectFactory::createModel('org.glizy.models.Registry');
     $rs->registry_path = $path;
     if ($rs->find()) {
         $rs->delete();
     }
 }
コード例 #15
0
 private function getPermissionName($permissions)
 {
     $names = array();
     $permissions = explode(',', $permissions);
     $ar = org_glizy_ObjectFactory::createModel('org.glizycms.roleManager.models.Role');
     foreach ($permissions as $v) {
         if ($ar->load($v)) {
             $names[] = array('id' => $ar->role_id, 'text' => $ar->role_name);
         }
     }
     return $names;
 }
コード例 #16
0
ファイル: Show.php プロジェクト: GruppoMeta/Movio
 function execute()
 {
     if (!$this->submit) {
         if (is_numeric($this->id)) {
             if ($this->id > 0) {
                 $this->ar = org_glizy_ObjectFactory::createModel($this->modelName);
                 $this->ar->load($this->id);
                 __Request::setFromArray($this->ar->getValuesAsArray());
             }
         } else {
             $this->changePage('link', array('pageId' => $this->pageId));
         }
     }
 }
コード例 #17
0
ファイル: Database.php プロジェクト: GruppoMeta/Movio
 public function logout()
 {
     org_glizy_Session::start();
     $evt = array('type' => GLZ_EVT_USERLOGOUT, 'data' => '');
     $this->dispatchEvent($evt);
     if (org_glizy_Config::get('USER_LOG')) {
         $user = org_glizy_Session::get('glizy.user');
         $arLog =& org_glizy_ObjectFactory::createModel('org.glizy.models.UserLog');
         $arLog->load($user['logId']);
         $arLog->delete();
     }
     org_glizy_Session::removeAll();
     setcookie("glizy_username", "", time() - 3600);
     setcookie("glizy_password", "", time() - 3600);
 }
コード例 #18
0
ファイル: AbstractMapping.php プロジェクト: GruppoMeta/Movio
 function loadRecord($id)
 {
     $this->ar = org_glizy_ObjectFactory::createModel($this->getModelName());
     $pk = $this->ar->getPrimarykey();
     $versionFieldName = $this->ar->getVersionFieldName();
     $languageFieldName = $this->ar->getLanguageFieldName();
     $this->ar->setFieldValue($pk, $id);
     if (!is_null($versionFieldName)) {
         $this->ar->setFieldValue($versionFieldName, 'PUBLISHED');
     }
     if (!is_null($languageFieldName)) {
         $this->ar->setFieldValue($languageFieldName, $this->application->getLanguageId());
     }
     return $this->ar->find();
 }
コード例 #19
0
 function postSave()
 {
     $values = $this->parent->{$this->bindTo};
     if (is_null($values)) {
         return;
     }
     $values = is_string($values) ? !empty($values) ? explode(',', $values) : array() : $values;
     if (!is_array($values)) {
         $values = array($values);
     }
     if (is_null($this->record->{$this->destinationKey}) || $this->record->{$this->destinationKey} == $this->record->getField($this->destinationKey)->defaultValue || is_null($this->iterator)) {
         // nuovo record
         $parentId = $this->parent->getId();
         foreach ($values as $v) {
             $this->record = org_glizy_ObjectFactory::createModel($this->className);
             $this->record->{$this->key} = $parentId;
             $this->record->{$this->destinationKey} = $v;
             $this->record->{$this->objectField} = $this->objectName;
             $this->record->save();
         }
     } else {
         $recordIds = array();
         foreach ($this->iterator as $ar) {
             if ($this->ordered) {
                 if (!$this->newRecord) {
                     $ar->delete();
                 }
             } else {
                 if (!in_array($ar->{$this->destinationKey}, $values)) {
                     $ar->delete();
                 } else {
                     $recordIds[] = $ar->{$this->destinationKey};
                 }
             }
         }
         if (count($values)) {
             foreach ($values as $v) {
                 if (!in_array($v, $recordIds)) {
                     $this->record = org_glizy_ObjectFactory::createModel($this->className);
                     $this->record->{$this->key} = $this->parent->getId();
                     $this->record->{$this->destinationKey} = $v;
                     $this->record->{$this->objectField} = $this->objectName;
                     $newId = $this->record->save();
                 }
             }
         }
     }
 }
コード例 #20
0
ファイル: PostComment.php プロジェクト: GruppoMeta/Movio
 public function execute($hash, $authorName, $authorEmail, $text, $captcha)
 {
     $valid = true;
     $error = '';
     if (!($hash && $authorName && $authorEmail && $text && $captcha)) {
         $valid = false;
         $error = 'Wrong input';
     }
     if ($valid && !filter_var($authorEmail, FILTER_VALIDATE_EMAIL)) {
         $valid = false;
         $error = 'Wrong email';
     }
     $sessionEx = new org_glizy_SessionEx($this->application->getPageId());
     $verCaptcha = $sessionEx->get('captcha' . $hash);
     if ($valid && $verCaptcha != $captcha) {
         $valid = false;
         $error = 'Wrong verify code';
     }
     if ($valid) {
         $ar = org_glizy_ObjectFactory::createModel('movio.modules.storyteller.models.Comment');
         $ar->hash = $hash;
         $ar->menuId = $this->application->getPageId();
         $ar->authorName = $authorName;
         $ar->authorEmail = $authorEmail;
         $ar->approved = 1;
         $ar->date = new org_glizy_types_Date();
         $ar->text = nl2br($text);
         $ar->save();
         $sessionEx->remove($hash . '_author');
         $sessionEx->remove($hash . '_email');
         $sessionEx->remove($hash . '_text');
         $sessionEx->remove($hash . '_error');
         $destHash = '#comments_' . $hash;
     } else {
         $sessionEx->set($hash . '_author', $authorName);
         $sessionEx->set($hash . '_email', $authorEmail);
         $sessionEx->set($hash . '_text', $text);
         $sessionEx->set($hash . '_error', $error);
         $destHash = '#form_' . $hash;
     }
     $this->goHere(null, $destHash);
 }
コード例 #21
0
ファイル: LostPassword.php プロジェクト: GruppoMeta/Movio
 public function executeLater($email)
 {
     if ($this->submit && $this->controller->validate()) {
         $ar = org_glizy_ObjectFactory::createModel('org.glizy.models.User');
         if (!$ar->find(array('user_email' => $email))) {
             // utente non trovato
             $this->view->validateAddError(__T('MW_LOSTPASSWORD_ERROR'));
             return false;
         }
         // utente trovato
         // genera una nuova password e la invia per email
         glz_import('org.glizy.helpers.Mail');
         // invia la notifica all'utente
         $subject = org_glizy_locale_Locale::get('MW_LOSTPASSWORD_EMAIL_SUBJECT');
         $body = org_glizy_locale_Locale::get('MW_LOSTPASSWORD_EMAIL_BODY');
         $body = str_replace('##USER##', $email, $body);
         $body = str_replace('##HOST##', org_glizy_helpers_Link::makeSimpleLink(GLZ_HOST, GLZ_HOST), $body);
         $body = str_replace('##PASSWORD##', $ar->user_password, $body);
         org_glizy_helpers_Mail::sendEmail(array('email' => org_glizy_Request::get('email', ''), 'name' => $ar->user_firstName . ' ' . $ar->user_lastName), array('email' => org_glizy_Config::get('SMTP_EMAIL'), 'name' => org_glizy_Config::get('SMTP_SENDER')), $subject, $body);
         $this->changeAction('lostPasswordConfirm');
     }
 }
コード例 #22
0
ファイル: Properties.php プロジェクト: GruppoMeta/Movio
 public function execute($menuId)
 {
     if ($menuId) {
         $menu = org_glizy_ObjectFactory::createModel('org.glizycms.core.models.Menu');
         $menu->load($menuId);
         $data = $menu->getValuesAsArray();
         // TODO controllase se il componente deve essere nascosto
         // quando ci sono pagine che devono essere usate una sola volta
         $this->setComponentsAttribute('menu_pageType', 'hide', $menu->menu_type == 'SYSTEM');
         $menuDetail = org_glizy_ObjectFactory::createModel('org.glizycms.core.models.MenuDetail');
         $menuDetail->find(array('menudetail_FK_menu_id' => $menuId, 'menudetail_FK_language_id' => org_glizy_ObjectValues::get('org.glizy', 'editingLanguageId')));
         $data = array_merge($data, $menuDetail->getValuesAsArray());
         if ($menu->menu_parentId) {
             $menuParent = org_glizy_ObjectFactory::createModel('org.glizycms.core.models.Menu');
             $menuParent->load($menu->menu_parentId);
             $data['menu_parentPageType'] = $menuParent->menu_pageType;
         }
         if ($this->user->acl('glizycms', 'page.properties.modifyPageTypeFree')) {
             $this->setComponentsAttribute('menu_pageType', 'linked', '');
         }
         $this->view->setData($data);
     }
 }
コード例 #23
0
ファイル: SaveProperties.php プロジェクト: GruppoMeta/Movio
 public function execute($data)
 {
     // TODO: controllo acl
     $data = json_decode($data);
     $menu = org_glizy_ObjectFactory::createModel('org.glizycms.core.models.Menu');
     $menu->load($data->menu_id);
     $menu->menu_url = $data->menu_url;
     $menu->menu_isLocked = $data->menu_isLocked;
     $menu->menu_hasComment = $data->menu_hasComment;
     $menu->menu_printPdf = $data->menu_printPdf;
     $menu->menu_pageType = $data->menu_pageType;
     $menu->menu_cssClass = $data->menu_cssClass;
     if (@$data->menu_creationDate) {
         $menu->menu_creationDate = $data->menu_creationDate;
     }
     $menu->save();
     $menu = org_glizy_ObjectFactory::createModel('org.glizycms.core.models.MenuDetail');
     $menu->find(array('menudetail_FK_menu_id' => $data->menu_id, 'menudetail_FK_language_id' => org_glizy_ObjectValues::get('org.glizy', 'editingLanguageId')));
     $menu->menudetail_title = $data->menudetail_title;
     $menu->menudetail_titleLink = $data->menudetail_titleLink;
     $menu->menudetail_linkDescription = $data->menudetail_linkDescription;
     $menu->menudetail_keywords = $data->menudetail_keywords;
     $menu->menudetail_description = $data->menudetail_description;
     $menu->menudetail_subject = $data->menudetail_subject;
     $menu->menudetail_creator = $data->menudetail_creator;
     $menu->menudetail_publisher = $data->menudetail_publisher;
     $menu->menudetail_contributor = $data->menudetail_contributor;
     $menu->menudetail_type = $data->menudetail_type;
     $menu->menudetail_identifier = $data->menudetail_identifier;
     $menu->menudetail_source = $data->menudetail_source;
     $menu->menudetail_relation = $data->menudetail_relation;
     $menu->menudetail_coverage = $data->menudetail_coverage;
     $menu->save();
     $menuProxy = org_glizy_ObjectFactory::createObject('org.glizycms.contents.models.proxy.MenuProxy');
     $menuProxy->invalidateSitemapCache();
     return true;
 }
コード例 #24
0
ファイル: SavePermissions.php プロジェクト: GruppoMeta/Movio
 public function execute($data)
 {
     // TODO: controllo acl
     $data = json_decode($data);
     $aclBack = implode(',', $data->aclBack);
     $aclFront = implode(',', $data->aclFront);
     $ar = org_glizy_ObjectFactory::createModel('org.glizycms.contents.models.Menu');
     $ar->load($data->menuId);
     //$ar->aclBack = $data->editPermissions;
     //$ar->aclFront = $data->viewPermissions;
     $ar->menu_extendsPermissions = $data->extendsPermissions;
     $ar->menu_isLocked = $aclFront ? 1 : 0;
     $ar->save();
     $tableName = $ar->getTableName();
     $ar = org_glizy_ObjectFactory::createModel('org.glizy.models.JoinDoctrine');
     $ar->delete(array('join_objectName' => $tableName . '#rel_aclBack'));
     $ar->delete(array('join_objectName' => $tableName . '#rel_aclFront'));
     if ($aclBack != '') {
         $aclBack = explode(',', $aclBack);
         foreach ($aclBack as $role) {
             $ar->join_FK_source_id = $data->menuId;
             $ar->join_FK_dest_id = $role;
             $ar->join_objectName = $tableName . '#rel_aclBack';
             $ar->save(null, true);
         }
     }
     if ($aclFront != '') {
         $aclFront = explode(',', $aclFront);
         foreach ($aclFront as $role) {
             $ar->join_FK_source_id = $data->menuId;
             $ar->join_FK_dest_id = $role;
             $ar->join_objectName = $tableName . '#rel_aclFront';
             $ar->save(null, true);
         }
     }
     return true;
 }
コード例 #25
0
ファイル: ShowExif.php プロジェクト: GruppoMeta/Movio
    function render()
    {
        if (!__Config::get('glizycms.mediaArchive.exifEnabled')) {
            return;
        }
        $ar = org_glizy_ObjectFactory::createModel('org.glizycms.models.Media');
        $ar->load($this->imageId);
        if ($ar->media_type == 'IMAGE') {
            $ar = org_glizy_ObjectFactory::createModel('org.glizycms.mediaArchive.models.Exif');
            $result = $ar->find(array('exif_FK_media_id' => $this->imageId));
            $values = array(__T('Dimension') => array('values' => array($ar->exif_imageWidth, $ar->exif_imageHeight), 'format' => '%dx%d'), __T('Resolution') => array('values' => array($ar->exif_resolution), 'format' => '%s dpi'), __T('Device manufacturer') => array('values' => array($ar->exif_make)), __T('Device model') => array('values' => array($ar->exif_model)), __T('Exposure time') => array('values' => array($ar->exif_exposureTime), 'format' => '%s s'), __T('Aperture') => array('values' => array($this->eval_rational($ar->exif_fNumber)), 'format' => '%.1f f'), __T('Exposure program') => array('values' => array($ar->exif_exposureProgram)), __T('ISO') => array('values' => array($ar->exif_ISOSpeedRatings)), __T('Original date') => array('values' => array($ar->exif_dateTimeOriginal)), __T('Digitized date') => array('values' => array($ar->exif_dateTimeDigitized)), __T('GPS coordinates') => array('values' => array($ar->exif_GPSCoords)), __T('GPS time') => array('values' => array($ar->exif_GPSTimeStamp)));
            $li = $this->formatValues($values);
            if ($result) {
                $output = <<<EOD
    <ul>
        {$li}
    </ul>
EOD;
            } else {
                $output = '<fieldset class="exif">' . __T('No exif data') . '</fieldset>';
            }
            $this->addOutputCode($output);
        }
    }
コード例 #26
0
ファイル: Permissions.php プロジェクト: GruppoMeta/Movio
 public function execute($menuId)
 {
     if ($menuId) {
         $menu = org_glizy_ObjectFactory::createModel('org.glizycms.contents.models.Menu');
         $menu->load($menuId);
         //inserire menu_extendsPermissions nella tabella menus_tbl
         $data = new StdClass();
         $data->extendsPermissions = $menu->menu_extendsPermissions;
         $tableName = $menu->getTableName();
         $aclBack = array();
         $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.contents.models.Role')->load('getAclBack', array('menuId' => $menuId, 'tableName' => $tableName));
         foreach ($it as $ar) {
             $aclBack[] = array('id' => $ar->role_id, 'text' => $ar->role_name);
         }
         $aclFront = array();
         $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.contents.models.Role')->load('getAclFront', array('menuId' => $menuId, 'tableName' => $tableName));
         foreach ($it as $ar) {
             $aclFront[] = array('id' => $ar->role_id, 'text' => $ar->role_name);
         }
         $data->aclBack = $aclBack;
         $data->aclFront = $aclFront;
         $this->view->setData($data);
     }
 }
コード例 #27
0
ファイル: Save.php プロジェクト: GruppoMeta/Movio
 private function checkDuplicates($medias)
 {
     // controlla se il file esiste già nell'archivio
     $ar = org_glizy_ObjectFactory::createModel('org.glizycms.models.Media');
     if ($ar->getField('media_md5')) {
         for ($i = 0; $i < count($medias->__uploadFilename); $i++) {
             if (!$medias->__uploadFilename[$i]) {
                 continue;
             }
             $md5 = md5_file(realpath($medias->__uploadFilename[$i]));
             $ar->emptyRecord();
             $result = $ar->find(array('media_md5' => $md5));
             if ($result) {
                 return array('errors' => array(__T('File already in media archive', $medias->__originalFileName[$i])));
             }
         }
     }
     return true;
 }
コード例 #28
0
ファイル: MediaProxy.php プロジェクト: GruppoMeta/Movio
 public function saveMedia($data, $action = self::MOVE_TO_CMS, $createRecordIfFileNotExists = false)
 {
     $filePath = $data->__filePath;
     $filePathThumb = property_exists($data, '__filePathThumb') ? $data->__filePathThumb : '';
     // controlla che il file esista
     if (!file_exists($filePath)) {
         if ($createRecordIfFileNotExists) {
             return $this->createMediaRecord($data);
         } else {
             return array('errors' => array('Il file ' . $filePath . ' non esiste'));
         }
     }
     $originalFileName = $data->__originalFileName;
     $fileSize = filesize($filePath);
     $fileExtension = strtolower(pathinfo($data->__originalFileName, PATHINFO_EXTENSION));
     $fileType = org_glizycms_mediaArchive_MediaManager::getMediaTypeFromExtension($fileExtension);
     $saveExifData = __Config::get('glizycms.mediaArchive.exifEnabled') && $fileType == 'IMAGE';
     if ($saveExifData) {
         $exif = @exif_read_data($filePath);
     }
     if ($action != self::NONE) {
         $r = $this->copyFileInArchive($action, $filePath, $originalFileName, $fileType);
         if (!$r['status']) {
             return $r;
         }
         $data->media_fileName = $r['destName'];
         $fileDestinationPath = $r['destPath'];
         if ($filePathThumb) {
             $r = $this->copyFileInArchive($action, $filePathThumb, 'thumb_' . $originalFileName, $fileType);
             if (!$r['status']) {
                 return $r;
             }
             $filePathThumb = $r['destName'];
         }
         /*
                     $file_destname = md5(time()) . "_" . $originalFileName;
                     $destinationFolder = org_glizy_Paths::get('APPLICATION_MEDIA_ARCHIVE').ucfirst(strtolower($fileType));
                     $fileDestinationPath = $destinationFolder.'/'.$file_destname;
                     $data->media_fileName = $file_destname;
         
                     // verifica che la cartella di destinazione sia scrivibile
                     if (!is_writeable($destinationFolder)) {
                         return array('errors' => array('Rendere scrivibile la cartella '.$destinationFolder));
                     }
         
                     if ($action == self::MOVE_TO_CMS) {
                         rename($filePath, $fileDestinationPath);
                     } else if ($action == self::COPY_TO_CMS) {
                         copy($filePath, $fileDestinationPath);
                     }
         */
     } else {
         $fileDestinationPath = $filePath;
     }
     $media = org_glizy_ObjectFactory::createModel('org.glizycms.models.Media');
     $media->media_originalFileName = $originalFileName;
     $media->media_thumbFileName = $filePathThumb;
     $media->media_size = $fileSize;
     $media->media_type = $fileType;
     $media->media_FK_user_id = org_glizy_ObjectValues::get('org.glizy', 'userId');
     $media->media_creationDate = new org_glizy_types_DateTime();
     $media->media_modificationDate = new org_glizy_types_DateTime();
     $media->media_download = 0;
     $media->media_md5 = md5_file($fileDestinationPath);
     if ($fileExtension == 'tif' || $fileExtension == 'tiff') {
         $media->media_watermark = 1;
         $media->media_allowDownload = 0;
     } else {
         $media->media_allowDownload = 1;
         $media->media_watermark = 0;
     }
     foreach ($data as $k => $v) {
         // remove the system values
         if (strpos($k, '__') === 0 || !$media->fieldExists($k)) {
             continue;
         }
         $media->{$k} = $v;
     }
     if ($saveExifData) {
         if ($exif['COMPUTED']['Copyright'] && empty($ar->media_copyright)) {
             $ar->media_copyright = $exif['COMPUTED']['Copyright'];
         }
     }
     $mediaId = $media->save();
     if ($saveExifData) {
         $exifService = org_glizy_ObjectFactory::createObject('org.glizycms.mediaArchive.services.ExifService');
         $exifService->saveExifData($mediaId, $exif);
     }
     return $mediaId;
 }
コード例 #29
0
ファイル: ContentProxy.php プロジェクト: GruppoMeta/Movio
 /**
  * Save the content for a menu
  * @param  org_glizycms_contents_models_ContentVO $data       Content to save
  * @param  int  $languageId Language id
  * @param  boolean  $publish    Publish or save
  */
 public function saveContent(org_glizycms_contents_models_ContentVO $data, $languageId, $publish = true, $setMenuTitle = true)
 {
     $speakingUrlProxy = __Config::get('glizycms.speakingUrl') ? org_glizy_ObjectFactory::createObject('org.glizycms.speakingUrl.models.proxy.SpeakingUrlProxy') : null;
     // TODO gestire meglio gli errori tramite eccezioni
     $menuId = (int) $data->getId();
     if ($menuId) {
         $invalidateSitemapCache = false;
         $menuDocument = $this->readRawContentFromMenu($menuId, $languageId);
         $originalUrl = $menuDocument->url;
         $menuDocument->setDataFromContentVO($data);
         if ($speakingUrlProxy && $originalUrl != $menuDocument->url) {
             //valida l'url
             if (!$speakingUrlProxy->validate($menuDocument->url, $languageId, $menuId, 'org.glizycms.core.models.Content')) {
                 return 'Url non valido perché già utilizzato';
             }
         }
         // salva i dati
         if ($publish) {
             $menuDocument->publish(null, $data->getComment());
         } else {
             $menuDocument->save(null, false, 'PUBLISHED', $data->getComment());
         }
         if ($speakingUrlProxy && $originalUrl != $menuDocument->url) {
             // aggiorna l'url parlante
             $speakingUrlProxy = org_glizy_ObjectFactory::createModel('org.glizycms.speakingUrl.models.proxy.SpeakingUrlProxy');
             if ($menuDocument->url) {
                 $speakingUrlProxy->addUrl($menuDocument->url, $languageId, $menuId, 'org.glizycms.core.models.Content');
             } else {
                 $speakingUrlProxy->deleteUrl($languageId, $menuId, 'org.glizycms.core.models.Content');
             }
             $invalidateSitemapCache = true;
         }
         // aggiorna il titolo della pagina
         $menuProxy = org_glizy_ObjectFactory::createObject('org.glizycms.contents.models.proxy.MenuProxy');
         $menuProxy->touch($menuId, $languageId);
         $menu = $menuProxy->getMenuFromId($menuId, $languageId);
         if ($setMenuTitle && $menu->menudetail_title != $menuDocument->title) {
             $menuProxy->rename($menuId, $languageId, $menuDocument->title);
         }
         // TODO implementare meglio
         if (strtolower($menu->menu_pageType) == 'alias') {
             $menu->menu_url = 'alias:' . $data->link;
             $menu->save();
             $invalidateSitemapCache = true;
         }
         if ($invalidateSitemapCache) {
             $menuProxy->invalidateSitemapCache();
         }
         $evt = array('type' => org_glizycms_contents_events_Menu::SAVE_CONTENT);
         $this->dispatchEvent($evt);
         return true;
     } else {
         // TODO: errore dati non validi
     }
 }
コード例 #30
0
ファイル: ThesaurusProxy.php プロジェクト: GruppoMeta/Movio
 public function moveTerm($termId, $newParentId)
 {
     $ar = org_glizy_ObjectFactory::createModel('movio.modules.thesaurus.models.Term');
     $ar->load($termId);
     $ar->parentId = $newParentId;
     $ar->save();
 }