Example #1
0
 /**
  * Update SEO configuration.
  */
 function procAdminUpdateSEO()
 {
     $vars = Context::getRequestVars();
     $args = new stdClass();
     $args->meta_keywords = $vars->site_meta_keywords ? implode(', ', array_map('trim', explode(',', $vars->site_meta_keywords))) : '';
     $args->meta_description = trim(utf8_normalize_spaces($vars->site_meta_description));
     $oModuleController = getController('module');
     $oModuleController->updateModuleConfig('module', $args);
     Rhymix\Framework\Config::set('seo.main_title', trim(utf8_normalize_spaces($vars->seo_main_title)));
     Rhymix\Framework\Config::set('seo.subpage_title', trim(utf8_normalize_spaces($vars->seo_subpage_title)));
     Rhymix\Framework\Config::set('seo.document_title', trim(utf8_normalize_spaces($vars->seo_document_title)));
     Rhymix\Framework\Config::set('seo.og_enabled', $vars->og_enabled === 'Y');
     Rhymix\Framework\Config::set('seo.og_extract_description', $vars->og_extract_description === 'Y');
     Rhymix\Framework\Config::set('seo.og_extract_images', $vars->og_extract_images === 'Y');
     Rhymix\Framework\Config::set('seo.og_use_timestamps', $vars->og_use_timestamps === 'Y');
     // Save
     Rhymix\Framework\Config::save();
     $this->setMessage('success_updated');
     $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigSEO'));
 }
Example #2
0
 /**
  * @brief insert borad module
  **/
 function procBoardAdminInsertBoard($args = null)
 {
     // generate module model/controller object
     $oModuleController = getController('module');
     $oModuleModel = getModel('module');
     // setup the board module infortmation
     $args = Context::getRequestVars();
     $args->module = 'board';
     $args->mid = $args->board_name;
     if (is_array($args->use_status)) {
         $args->use_status = implode('|@|', $args->use_status);
     }
     unset($args->board_name);
     // setup extra_order_target
     $extra_order_target = array();
     if ($args->module_srl) {
         $oDocumentModel = getModel('document');
         $module_extra_vars = $oDocumentModel->getExtraKeys($args->module_srl);
         foreach ($module_extra_vars as $oExtraItem) {
             $extra_order_target[$oExtraItem->eid] = $oExtraItem->name;
         }
     }
     // setup other variables
     if ($args->except_notice != 'Y') {
         $args->except_notice = 'N';
     }
     if ($args->use_anonymous != 'Y') {
         $args->use_anonymous = 'N';
     }
     if ($args->consultation != 'Y') {
         $args->consultation = 'N';
     }
     if ($args->protect_content != 'Y') {
         $args->protect_content = 'N';
     }
     if (!in_array($args->order_target, $this->order_target) && !array_key_exists($args->order_target, $extra_order_target)) {
         $args->order_target = 'list_order';
     }
     if (!in_array($args->order_type, array('asc', 'desc'))) {
         $args->order_type = 'asc';
     }
     $args->browser_title = trim(utf8_normalize_spaces($args->browser_title));
     $args->meta_keywords = $args->meta_keywords ? implode(', ', array_map('trim', explode(',', $args->meta_keywords))) : '';
     $args->meta_description = trim(utf8_normalize_spaces($args->meta_description));
     // if there is an existed module
     if ($args->module_srl) {
         $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl);
         if ($module_info->module_srl != $args->module_srl) {
             unset($args->module_srl);
         }
     }
     // insert/update the board module based on module_srl
     if (!$args->module_srl) {
         $args->hide_category = 'N';
         $output = $oModuleController->insertModule($args);
         $msg_code = 'success_registed';
     } else {
         $args->hide_category = $module_info->hide_category;
         $output = $oModuleController->updateModule($args);
         $msg_code = 'success_updated';
     }
     if (!$output->toBool()) {
         return $output;
     }
     // setup list config
     $list = explode(',', Context::get('list'));
     if (count($list)) {
         $list_arr = array();
         foreach ($list as $val) {
             $val = trim($val);
             if (!$val) {
                 continue;
             }
             if (substr($val, 0, 10) == 'extra_vars') {
                 $val = substr($val, 10);
             }
             $list_arr[] = $val;
         }
         $oModuleController = getController('module');
         $oModuleController->insertModulePartConfig('board', $output->get('module_srl'), $list_arr);
     }
     $this->setMessage($msg_code);
     if (Context::get('success_return_url')) {
         changeValueInUrl('mid', $args->mid, $module_info->mid);
         $this->setRedirectUrl(Context::get('success_return_url'));
     } else {
         $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispBoardAdminBoardInfo', 'module_srl', $output->get('module_srl')));
     }
 }
Example #3
0
 /**
  * Add OpenGraph metadata tags.
  * 
  * @param string $output
  * @return void
  */
 function _addOpenGraphMetadata()
 {
     // Get information about the current request.
     $page_type = 'website';
     $current_module_info = Context::get('current_module_info');
     $site_module_info = Context::get('site_module_info');
     $document_srl = Context::get('document_srl');
     if ($document_srl) {
         $oDocument = Context::get('oDocument') ?: getModel('document')->getDocument($document_srl, false, false);
         if ($oDocument instanceof documentItem && $oDocument->document_srl == $document_srl && !$oDocument->isSecret()) {
             $page_type = 'article';
         }
     }
     // Add basic metadata.
     Context::addOpenGraphData('og:title', Context::getBrowserTitle());
     Context::addOpenGraphData('og:site_name', Context::getSiteTitle());
     if ($page_type === 'article' && config('seo.og_extract_description')) {
         $description = trim(utf8_normalize_spaces($oDocument->getContentText(200)));
     } else {
         $description = Context::getMetaTag('description');
     }
     Context::addOpenGraphData('og:description', $description);
     Context::addMetaTag('description', $description);
     // Add metadata about this page.
     Context::addOpenGraphData('og:type', $page_type);
     if ($page_type === 'article') {
         $canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl', $document_srl);
     } elseif (($page = Context::get('page')) > 1) {
         $canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'page', $page);
     } elseif ($current_module_info->module_srl == $site_module_info->module_srl) {
         $canonical_url = getFullUrl('');
     } else {
         $canonical_url = getFullUrl('', 'mid', $current_module_info->mid);
     }
     Context::addOpenGraphData('og:url', $canonical_url);
     Context::setCanonicalURL($canonical_url);
     // Add metadata about the locale.
     $lang_type = Context::getLangType();
     $locales = (include \RX_BASEDIR . 'common/defaults/locales.php');
     if (isset($locales[$lang_type])) {
         Context::addOpenGraphData('og:locale', $locales[$lang_type]['locale']);
     }
     if ($page_type === 'article' && $oDocument->getLangCode() !== $lang_type && isset($locales[$oDocument->getLangCode()])) {
         Context::addOpenGraphData('og:locale:alternate', $locales[$oDocument->getLangCode()]);
     }
     // Add image.
     if ($page_type === 'article' && config('seo.og_extract_images')) {
         if (($document_images = Rhymix\Framework\Cache::get("seo:document_images:{$document_srl}")) === null) {
             $document_images = array();
             if ($oDocument->hasUploadedFiles()) {
                 foreach ($oDocument->getUploadedFiles() as $file) {
                     if ($file->isvalid !== 'Y' || !preg_match('/\\.(?:bmp|gif|jpe?g|png)$/i', $file->uploaded_filename)) {
                         continue;
                     }
                     list($width, $height) = @getimagesize($file->uploaded_filename);
                     if ($width < 100 && $height < 100) {
                         continue;
                     }
                     $image = array('filepath' => $file->uploaded_filename, 'width' => $width, 'height' => $height);
                     if ($file->cover_image === 'Y') {
                         array_unshift($document_images, $image);
                     } else {
                         $document_images[] = $image;
                     }
                     if (count($document_images) >= 1) {
                         break;
                     }
                 }
             }
             Rhymix\Framework\Cache::set("seo:document_images:{$document_srl}", $document_images, 0, true);
         }
     } else {
         $document_images = null;
     }
     if ($document_images) {
         $first_image = reset($document_images);
         $first_image['filepath'] = preg_replace('/^.\\/files\\//', \RX_BASEURL . 'files/', $first_image['filepath']);
         Context::addOpenGraphData('og:image', Rhymix\Framework\URL::getCurrentDomainURL($first_image['filepath']));
         Context::addOpenGraphData('og:image:width', $first_image['width']);
         Context::addOpenGraphData('og:image:height', $first_image['height']);
     } elseif ($default_image = getAdminModel('admin')->getSiteDefaultImageUrl($width, $height)) {
         Context::addOpenGraphData('og:image', Rhymix\Framework\URL::getCurrentDomainURL($default_image));
         if ($width && $height) {
             Context::addOpenGraphData('og:image:width', $width);
             Context::addOpenGraphData('og:image:height', $height);
         }
     }
     // Add datetime for articles.
     if ($page_type === 'article' && config('seo.og_use_timestamps')) {
         Context::addOpenGraphData('article:published_time', $oDocument->getRegdate('c'));
         Context::addOpenGraphData('article:modified_time', $oDocument->getUpdate('c'));
     }
 }
Example #4
0
 /**
  * @brief Add a Page
  */
 function procPageAdminInsert()
 {
     // Create model/controller object of the module module
     $oModuleController = getController('module');
     $oModuleModel = getModel('module');
     // Set board module
     $args = Context::getRequestVars();
     $args->module = 'page';
     $args->mid = $args->page_name;
     //because if mid is empty in context, set start page mid
     $args->path = !$args->path ? '' : $args->path;
     $args->mpath = !$args->mpath ? '' : $args->mpath;
     unset($args->page_name);
     if ($args->use_mobile != 'Y') {
         $args->use_mobile = '';
     }
     $args->browser_title = trim(utf8_normalize_spaces($args->browser_title));
     $args->meta_keywords = $args->meta_keywords ? implode(', ', array_map('trim', explode(',', $args->meta_keywords))) : '';
     $args->meta_description = trim(utf8_normalize_spaces($args->meta_description));
     // Check if an original module exists by using module_srl
     if ($args->module_srl) {
         $columnList = array('module_srl');
         $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
         if ($module_info->module_srl != $args->module_srl) {
             unset($args->module_srl);
         } else {
             foreach ($args as $key => $val) {
                 $module_info->{$key} = $val;
             }
             $args = $module_info;
         }
     }
     switch ($args->page_type) {
         case 'WIDGET':
             unset($args->skin);
             unset($args->mskin);
             unset($args->path);
             unset($args->mpath);
             break;
         case 'ARTICLE':
             unset($args->page_caching_interval);
             unset($args->path);
             unset($args->mpath);
             break;
         case 'OUTSIDE':
             unset($args->skin);
             unset($args->mskin);
             break;
     }
     // Insert/update depending on module_srl
     if (!$args->module_srl) {
         $output = $oModuleController->insertModule($args);
         $msg_code = 'success_registed';
     } else {
         $output = $oModuleController->updateModule($args);
         $msg_code = 'success_updated';
     }
     if (!$output->toBool()) {
         return $output;
     }
     $this->add("page", Context::get('page'));
     $this->add('module_srl', $output->get('module_srl'));
     $this->setMessage($msg_code);
     $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'module_srl', $output->get('module_srl'), 'act', 'dispPageAdminInfo');
     $this->setRedirectUrl($returnUrl);
 }