diff --git a/application/modules/backend/views/scripts/store/index.phtml b/application/modules/backend/views/scripts/store/index.phtml index 4b5f63184..7a52ef2d2 100644 --- a/application/modules/backend/views/scripts/store/index.phtml +++ b/application/modules/backend/views/scripts/store/index.phtml @@ -1,400 +1,414 @@ . **/ ?>
getCurrentMessages() as $message) : ?>

escape($message); ?>

diff --git a/application/modules/default/Bootstrap.php b/application/modules/default/Bootstrap.php index 686737c3d..f0d921c54 100644 --- a/application/modules/default/Bootstrap.php +++ b/application/modules/default/Bootstrap.php @@ -1,852 +1,884 @@ . **/ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { /** * @return Zend_Application_Module_Autoloader * @throws Zend_Loader_Exception */ protected function _initAutoload() { $autoloader = new Zend_Application_Module_Autoloader(array( 'namespace' => 'Default', 'basePath' => realpath(dirname(__FILE__)), )); $autoloader->addResourceType('formelements', 'forms/elements', 'Form_Element'); $autoloader->addResourceType('formvalidators', 'forms/validators', 'Form_Validator'); return $autoloader; } /** * @throws Zend_Exception * @throws Zend_Session_Exception */ protected function _initSessionManagement() { $config = $this->getOption('settings')['session']; $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false; if ($config['saveHandler']['replace']['enabled']) { $cacheClass = 'Zend_Cache_Backend_' . $config['saveHandler']['cache']['type']; $_cache = new $cacheClass($config['saveHandler']['options']); Zend_Loader::loadClass($config['saveHandler']['class']); Zend_Session::setSaveHandler(new $config['saveHandler']['class']($_cache)); Zend_Session::setOptions(array( 'cookie_domain' => $domain, 'cookie_path' => $config['auth']['cookie_path'], 'cookie_lifetime' => $config['auth']['cookie_lifetime'], 'cookie_httponly' => $config['auth']['cookie_httponly'] )); Zend_Session::start(); } $session_namespace = new Zend_Session_Namespace($config['auth']['name']); $session_namespace->setExpirationSeconds($config['auth']['cookie_lifetime']); Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_Session($session_namespace->getNamespace())); } protected function _initConfig() { /** $config Zend_Config */ $config = $this->getApplication()->getApplicationConfig(); Zend_Registry::set('config', $config); return $config; } /** * @return mixed|null|Zend_Cache_Core|Zend_Cache_Frontend * @throws Zend_Cache_Exception * @throws Zend_Exception */ protected function _initCache() { if (Zend_Registry::isRegistered('cache')) { return Zend_Registry::get('cache'); } $cache = null; $options = $this->getOption('settings'); if (true == $options['cache']['enabled']) { $cache = Zend_Cache::factory($options['cache']['frontend']['type'], $options['cache']['backend']['type'], $options['cache']['frontend']['options'], $options['cache']['backend']['options']); } else { // Fallback settings for some (maybe development) environments which have no cache management installed. if (false === is_writeable(APPLICATION_CACHE)) { error_log('directory for cache files does not exists or not writable: ' . APPLICATION_CACHE); exit('directory for cache files does not exists or not writable: ' . APPLICATION_CACHE); } $frontendOptions = array( 'lifetime' => 600, 'automatic_serialization' => true, 'cache_id_prefix' => 'front_cache', 'cache' => true ); $backendOptions = array( 'cache_dir' => APPLICATION_CACHE, 'file_locking' => true, 'read_control' => true, 'read_control_type' => 'crc32', 'hashed_directory_level' => 1, 'hashed_directory_perm' => 0700, 'file_name_prefix' => 'ocs', 'cache_file_perm' => 0700 ); $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); } Zend_Registry::set('cache', $cache); Zend_Locale::setCache($cache); Zend_Locale_Data::setCache($cache); Zend_Currency::setCache($cache); Zend_Translate::setCache($cache); Zend_Translate_Adapter::setCache($cache); Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); Zend_Paginator::setCache($cache); return $cache; } /** * @throws Zend_Application_Bootstrap_Exception */ protected function _initViewConfig() { $view = $this->bootstrap('view')->getResource('view'); $view->addHelperPath(APPLICATION_PATH . '/modules/default/views/helpers', 'Default_View_Helper_'); $view->addHelperPath(APPLICATION_LIB . '/Zend/View/Helper', 'Zend_View_Helper_'); $options = $this->getOptions(); $docType = $options['resources']['view']['doctype'] ? $options['resources']['view']['doctype'] : 'XHTML1_TRANSITIONAL'; $view->doctype($docType); } /** * @throws Zend_Locale_Exception */ protected function _initLocale() { $configResources = $this->getOption('resources'); Zend_Locale::setDefault($configResources['locale']['default']); Zend_Registry::set($configResources['locale']['registry_key'], $configResources['locale']['default']); } /** * @return Zend_Translate * @throws Zend_Application_Resource_Exception * @throws Zend_Form_Exception * @throws Zend_Session_Exception * @throws Zend_Translate_Exception * @throws Zend_Validate_Exception */ protected function _initTranslate() { $options = $this->getOption('resources'); $options = $options['translate']; if (!isset($options['data'])) { throw new Zend_Application_Resource_Exception('not found the file'); } $adapter = isset($options['adapter']) ? $options['adapter'] : Zend_Translate::AN_ARRAY; $session = new Zend_Session_Namespace('aa'); if ($session->locale) { $locale = $session->locale; } else { $locale = isset($options['locale']) ? $options['locale'] : null; } $data = ''; if (isset($options['data'][$locale])) { $data = $options['data'][$locale]; } $translateOptions = isset($options['options']) ? $options['options'] : array(); $translate = new Zend_Translate($adapter, $data, $locale, $translateOptions); Zend_Form::setDefaultTranslator($translate); Zend_Validate_Abstract::setDefaultTranslator($translate); Zend_Registry::set('Zend_Translate', $translate); return $translate; } /** * @throws Zend_Application_Bootstrap_Exception */ protected function _initDbAdapter() { $db = $this->bootstrap('db')->getResource('db'); //( if ((APPLICATION_ENV == 'development') OR (APPLICATION_ENV == 'testing')) { // $profiler = new Zend_Db_Profiler_Firebug('All DB Queries'); // $profiler->setEnabled(true); // // // Attach the profiler to your db adapter // $db->setProfiler($profiler); // } Zend_Registry::set('db', $db); Zend_Db_Table::setDefaultAdapter($db); Zend_Db_Table_Abstract::setDefaultAdapter($db); } /** * @throws Zend_Log_Exception */ protected function _initLogger() { $settings = $this->getOption('settings'); $log = new Zend_Log(); $writer = new Zend_Log_Writer_Stream($settings['log']['path'] . 'all_' . date("Y-m-d")); $writer->addFilter(new Local_Log_Filter_MinMax(Zend_Log::WARN, Zend_Log::DEBUG)); $log->addWriter($writer); $errorWriter = new Zend_Log_Writer_Stream($settings['log']['path'] . 'err_' . date('Y-m-d')); $errorWriter->addFilter(new Zend_Log_Filter_Priority(Zend_Log::ERR)); $log->addWriter($errorWriter); Zend_Registry::set('logger', $log); if ((APPLICATION_ENV == 'development') OR (APPLICATION_ENV == 'testing')) { $firebugWriter = new Zend_Log_Writer_Firebug(); $firebugLog = new Zend_Log($firebugWriter); Zend_Registry::set('firebug_log', $firebugLog); } } protected function _initGlobals() { Zend_Paginator::setDefaultScrollingStyle('Elastic'); Zend_View_Helper_PaginationControl::setDefaultViewPartial('paginationControl.phtml'); Zend_Filter::addDefaultNamespaces('Local_Filter'); $version = $this->getOption('version'); defined('APPLICATION_VERSION') || define('APPLICATION_VERSION', $version); } /** * @return Default_Plugin_AclRules|false|mixed * @throws Zend_Cache_Exception */ protected function _initAclRules() { /** @var Zend_Cache_Core $appCache */ $appCache = $this->getResource('cache'); if (false == ($aclRules = $appCache->load('AclRules'))) { $aclRules = new Default_Plugin_AclRules(); Zend_Registry::set('acl', $aclRules); $appCache->save($aclRules, 'AclRules', array('AclRules'), 14400); } return $aclRules; } /** * @throws Zend_Application_Bootstrap_Exception * @throws Zend_Loader_PluginLoader_Exception */ protected function _initPlugins() { /** @var $front Zend_Controller_Front */ $front = $this->bootstrap('frontController')->getResource('frontController'); $aclRules = $this->bootstrap('aclRules')->getResource('aclRules'); $front->unregisterPlugin('Zend_Controller_Plugin_ErrorHandler'); $front->registerPlugin(new Default_Plugin_ErrorHandler()); $front->registerPlugin(new Default_Plugin_RememberMe(Zend_Auth::getInstance())); $front->registerPlugin(new Default_Plugin_SignOn(Zend_Auth::getInstance())); $front->registerPlugin(new Default_Plugin_Acl(Zend_Auth::getInstance(), $aclRules)); $loader = new Zend_Loader_PluginLoader(); $loader->addPrefixPath('Zend_View_Helper', APPLICATION_LIB . '/Zend/View/Helper/') ->addPrefixPath('Zend_Form_Element', APPLICATION_LIB . '/Zend/Form/Element') ->addPrefixPath('Default_View_Helper', APPLICATION_PATH . '/modules/default/views/helpers') ->addPrefixPath('Default_Form_Helper', APPLICATION_PATH . '/modules/default/forms/helpers') ->addPrefixPath('Default_Form_Element', APPLICATION_PATH . '/modules/default/forms/elements') ->addPrefixPath('Default_Form_Decorator', APPLICATION_PATH . '/modules/default/forms/decorators') ->addPrefixPath('Default_Form_Validator', APPLICATION_PATH . '/modules/default/forms/validators') ; } protected function _initThirdParty() { $appConfig = $this->getResource('config'); $imageConfig = $appConfig->images; defined('IMAGES_UPLOAD_PATH') || define('IMAGES_UPLOAD_PATH', $imageConfig->upload->path); defined('IMAGES_MEDIA_SERVER') || define('IMAGES_MEDIA_SERVER', $imageConfig->media->server); // ppload $pploadConfig = $appConfig->third_party->ppload; defined('PPLOAD_API_URI') || define('PPLOAD_API_URI', $pploadConfig->api_uri); defined('PPLOAD_CLIENT_ID') || define('PPLOAD_CLIENT_ID', $pploadConfig->client_id); defined('PPLOAD_SECRET') || define('PPLOAD_SECRET', $pploadConfig->secret); defined('PPLOAD_DOWNLOAD_SECRET') || define('PPLOAD_DOWNLOAD_SECRET', $pploadConfig->download_secret); } /** * @return false|mixed|Zend_Controller_Router_Rewrite * @throws Zend_Application_Bootstrap_Exception * @throws Zend_Cache_Exception * @throws Zend_Controller_Exception * @throws Zend_Exception */ protected function _initRouter() { $this->bootstrap('frontController'); /** @var $front Zend_Controller_Front */ $front = $this->getResource('frontController'); /** @var Zend_Cache_Core $cache */ $cache = Zend_Registry::get('cache'); if (($router = $cache->load('ProjectRouter'))) { $front->setRouter($router); return $router; } /** @var $router Zend_Controller_Router_Rewrite */ $router = $front->getRouter(); /** RSS Feed */ $router->addRoute('rdf_store', new Zend_Controller_Router_Route('/content.rdf', array( 'module' => 'default', 'controller' => 'rss', 'action' => 'rdf' ))); $router->addRoute('rdf_events_hive', new Zend_Controller_Router_Route_Regex('.*-events.rss', array( 'module' => 'default', 'controller' => 'rss', 'action' => 'rss' ))); $router->addRoute('rdf_store_hive', new Zend_Controller_Router_Route_Regex('.*-content.rdf', array( 'module' => 'default', 'controller' => 'rss', 'action' => 'rdf' ))); $router->addRoute('rdf_store_hive_rss', new Zend_Controller_Router_Route_Regex('rss/.*-content.rdf', array( 'module' => 'default', 'controller' => 'rss', 'action' => 'rdf' ))); /** new store dependent routing rules */ //$router->addRoute('store_general', new Zend_Controller_Router_Route('/s/:domain_store_id/:controller/:action/*', array( // 'module' => 'default', // 'controller' => 'explore', // 'action' => 'index' //))); $router->addRoute('store_home', new Zend_Controller_Router_Route('/s/:domain_store_id/', array( 'module' => 'default', 'controller' => 'home', 'action' => 'index' ))); $router->addRoute('store_browse', new Zend_Controller_Router_Route('/s/:domain_store_id/browse/*', array( 'module' => 'default', 'controller' => 'explore', 'action' => 'index' ))); $router->addRoute('store_product_add', new Zend_Controller_Router_Route('/s/:domain_store_id/product/add', array( 'module' => 'default', 'controller' => 'product', 'action' => 'add' ))); + + $router->addRoute('store_settings', new Zend_Controller_Router_Route('/s/:domain_store_id/settings', array( + 'module' => 'default', + 'controller' => 'settings', + 'action' => 'index' + ))); + + $router->addRoute('store_pling_box_show', new Zend_Controller_Router_Route('/s/:domain_store_id/supporterbox/:memberid', array( + 'module' => 'default', + 'controller' => 'plingbox', + 'action' => 'index' + ))); + + $router->addRoute('store_pling_box_show', new Zend_Controller_Router_Route('/s/:domain_store_id/productcomment/addreply/*', array( + 'module' => 'default', + 'controller' => 'productcomment', + 'action' => 'addreply' + ))); $router->addRoute('store_product', new Zend_Controller_Router_Route('/s/:domain_store_id/p/:project_id/:action/*', array( 'module' => 'default', 'controller' => 'product', 'action' => 'show' ))); $router->addRoute('store_user', new Zend_Controller_Router_Route('/s/:domain_store_id/member/:member_id/:action/*', array( 'module' => 'default', 'controller' => 'user', 'action' => 'index' ))); $router->addRoute('store_user_name', new Zend_Controller_Router_Route('/s/:domain_store_id/u/:user_name/:action/*', array( 'module' => 'default', 'controller' => 'user', 'action' => 'index' ))); + + $router->addRoute('store_login', new Zend_Controller_Router_Route('/s/:domain_store_id/login/*', array( + 'module' => 'default', + 'controller' => 'authorization', + 'action' => 'login' + ))); + + $router->addRoute('store_register', new Zend_Controller_Router_Route('/s/:domain_store_id/register', array( + 'module' => 'default', + 'controller' => 'authorization', + 'action' => 'register' + ))); + + /** general routing rules */ $router->addRoute('home', new Zend_Controller_Router_Route('/', array( 'module' => 'default', 'controller' => 'home', 'action' => 'index' ))); $router->addRoute('home_ajax', new Zend_Controller_Router_Route('/showfeatureajax/*', array( 'module' => 'default', 'controller' => 'home', 'action' => 'showfeatureajax' ))); $router->addRoute('backend', new Zend_Controller_Router_Route('/backend/:controller/:action/*', array( 'module' => 'backend', 'controller' => 'index', 'action' => 'index' ))); $router->addRoute('browse', new Zend_Controller_Router_Route('/browse/*', array( 'module' => 'default', 'controller' => 'explore', 'action' => 'index' ))); $router->addRoute('button_render', new Zend_Controller_Router_Route('/button/:project_id/:size/', array( 'module' => 'default', 'controller' => 'button', 'action' => 'render', 'size' => 'large' ))); $router->addRoute('button_action', new Zend_Controller_Router_Route('/button/a/:action/', array( 'module' => 'default', 'controller' => 'button', 'action' => 'index' ))); $router->addRoute('pling_box_show', new Zend_Controller_Router_Route('/supporterbox/:memberid/', array( 'module' => 'default', 'controller' => 'plingbox', 'action' => 'index' ))); $router->addRoute('external_donation_list', new Zend_Controller_Router_Route('/donationlist/:project_id/', array( 'module' => 'default', 'controller' => 'donationlist', 'action' => 'render' ))); $router->addRoute('external_widget', new Zend_Controller_Router_Route('/widget/:project_id/', array( 'module' => 'default', 'controller' => 'widget', 'action' => 'render' ))); $router->addRoute('external_widget_save', new Zend_Controller_Router_Route('/widget/save/*', array( 'module' => 'default', 'controller' => 'widget', 'action' => 'save' ))); $router->addRoute('external_widget_save', new Zend_Controller_Router_Route('/widget/config/:project_id/', array( 'module' => 'default', 'controller' => 'widget', 'action' => 'config' ))); $router->addRoute('external_widget_save_default', new Zend_Controller_Router_Route('/widget/savedefault/*', array( 'module' => 'default', 'controller' => 'widget', 'action' => 'savedefault' ))); /** * Project/Product */ $router->addRoute('product_short_url', new Zend_Controller_Router_Route('/p/:project_id/:action/*', array( 'module' => 'default', 'controller' => 'product', 'action' => 'show' ))); $router->addRoute('product_referrer_url', new Zend_Controller_Router_Route('/p/:project_id/er/:er/*', array( 'module' => 'default', 'controller' => 'product', 'action' => 'show' ))); $router->addRoute('product_collectionid_url', new Zend_Controller_Router_Route('/c/:collection_id', array( 'module' => 'default', 'controller' => 'product', 'action' => 'show' ))); $router->addRoute('product_add', new Zend_Controller_Router_Route('/product/add', array( 'module' => 'default', 'controller' => 'product', 'action' => 'add' ))); $router->addRoute('search', new Zend_Controller_Router_Route('/search/*', array( 'module' => 'default', 'controller' => 'product', 'action' => 'search' ))); $router->addRoute('search_domain',new Zend_Controller_Router_Route('/s/:domain_store_id/search/*', array( 'module' => 'default', 'controller' => 'product', 'action' => 'search' ))); $router->addRoute('product_save', new Zend_Controller_Router_Route('/p/save/*', array( 'module' => 'default', 'controller' => 'product', 'action' => 'saveproduct' ))); /** * Member */ $router->addRoute('member_settings_old', new Zend_Controller_Router_Route('/settings/:action/*', array( 'module' => 'default', 'controller' => 'settings', 'action' => 'index' ))); $router->addRoute('user_show', new Zend_Controller_Router_Route('/member/:member_id/:action/*', array( 'module' => 'default', 'controller' => 'user', 'action' => 'index' ))); $router->addRoute('user_avatar', new Zend_Controller_Router_Route('/member/avatar/:emailhash/:size', array( 'module' => 'default', 'controller' => 'user', 'action' => 'avatar' ))); $router->addRoute('user_show_with_name', new Zend_Controller_Router_Route('/u/:user_name/:action/*', array( 'module' => 'default', 'controller' => 'user', 'action' => 'index' ))); $router->addRoute('user_recification', new Zend_Controller_Router_Route('/r/:action/*', array( 'module' => 'default', 'controller' => 'rectification', 'action' => 'index' ))); $router->addRoute('user_show_short', new Zend_Controller_Router_Route('/me/:member_id/:action/*', array( 'module' => 'default', 'controller' => 'user', 'action' => 'index' ))); $router->addRoute('register', new Zend_Controller_Router_Route_Static('/register', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'register' ))); $router->addRoute('register_validate', new Zend_Controller_Router_Route_Static('/register/validate', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'validate' ))); $router->addRoute('verification', new Zend_Controller_Router_Route('/verification/:vid', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'verification' ))); $router->addRoute('logout', new Zend_Controller_Router_Route_Static('/logout', array( 'module' => 'default', 'controller' => 'logout', 'action' => 'logout' ))); $router->addRoute('propagatelogout', new Zend_Controller_Router_Route_Static('/logout/propagate', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'propagatelogout' ))); $router->addRoute('checkuser', new Zend_Controller_Router_Route_Static('/checkuser', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'checkuser' ))); $router->addRoute('login', new Zend_Controller_Router_Route('/login', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'login' ))); $router->addRoute('login', new Zend_Controller_Router_Route('/login/:action/*', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'login' ))); $router->addRoute('LoginController', new Zend_Controller_Router_Route('/l/:action/*', array( 'module' => 'default', 'controller' => 'login', 'action' => 'login' ))); $router->addRoute('content', new Zend_Controller_Router_Route('/content/:page', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index' ))); $router->addRoute('categories_about', new Zend_Controller_Router_Route('/cat/:page/about', array( 'module' => 'default', 'controller' => 'categories', 'action' => 'about' ))); // **** static routes $router->addRoute('static_faq', new Zend_Controller_Router_Route_Static('/faq', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index', 'page' => 'faq' ))); $router->addRoute('static_terms', new Zend_Controller_Router_Route_Static('/terms', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index', 'page' => 'terms' ))); $router->addRoute('static_terms_general', new Zend_Controller_Router_Route_Static('/terms/general', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index', 'page' => 'terms-general' ))); $router->addRoute('static_terms_publish', new Zend_Controller_Router_Route_Static('/terms/publishing', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index', 'page' => 'terms-publishing' ))); $router->addRoute('static_terms_dmca', new Zend_Controller_Router_Route_Static('/terms/dmca', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index', 'page' => 'terms-dmca' ))); $router->addRoute('static_privacy', new Zend_Controller_Router_Route_Static('/privacy', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index', 'page' => 'privacy' ))); $router->addRoute('static_contact', new Zend_Controller_Router_Route_Static('/contact', array( 'module' => 'default', 'controller' => 'content', 'action' => 'index', 'page' => 'contact' ))); // **** ppload $router->addRoute('pploadlogin', new Zend_Controller_Router_Route('/pploadlogin/*', array( 'module' => 'default', 'controller' => 'authorization', 'action' => 'pploadlogin' ))); // OCS API $router->addRoute('ocs_providers_xml', new Zend_Controller_Router_Route('/ocs/providers.xml', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'providers' ))); $router->addRoute('ocs_v1_config', new Zend_Controller_Router_Route('/ocs/v1/config', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'config' ))); $router->addRoute('ocs_v1_person_check', new Zend_Controller_Router_Route('/ocs/v1/person/check', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'personcheck' ))); $router->addRoute('ocs_v1_person_data', new Zend_Controller_Router_Route('/ocs/v1/person/data', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'persondata' ))); $router->addRoute('ocs_v1_person_data_personid', new Zend_Controller_Router_Route('/ocs/v1/person/data/:personid', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'persondata' ))); $router->addRoute('ocs_v1_person_self', new Zend_Controller_Router_Route('/ocs/v1/person/self', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'personself' ))); $router->addRoute('ocs_v1_content_categories', new Zend_Controller_Router_Route('/ocs/v1/content/categories', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'contentcategories' ))); $router->addRoute('ocs_v1_content_data_contentid', new Zend_Controller_Router_Route('/ocs/v1/content/data/:contentid', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'contentdata', 'contentid' => null ))); $router->addRoute('ocs_v1_content_download_contentid_itemid', new Zend_Controller_Router_Route('/ocs/v1/content/download/:contentid/:itemid', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'contentdownload' ))); $router->addRoute('ocs_v1_content_previewpic_contentid', new Zend_Controller_Router_Route('/ocs/v1/content/previewpic/:contentid', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'contentpreviewpic' ))); $router->addRoute('ocs_v1_comments', new Zend_Controller_Router_Route('/ocs/v1/comments/data/:comment_type/:content_id/:second_id', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'comments', 'comment_type' => -1, 'content_id' => null, 'second_id' => null ))); $router->addRoute('ocs_v1_voting', new Zend_Controller_Router_Route('/ocs/v1/content/vote/:contentid', array( 'module' => 'default', 'controller' => 'ocsv1', 'action' => 'vote' ))); // embed $router->addRoute('embed_v1_member_projects', new Zend_Controller_Router_Route('/embed/v1/member/:memberid', array( 'module' => 'default', 'controller' => 'embedv1', 'action' => 'memberprojects' ))); $router->addRoute('embed_v1_member_projects_files', new Zend_Controller_Router_Route('/embed/v1/ppload/:ppload_collection_id', array( 'module' => 'default', 'controller' => 'embedv1', 'action' => 'ppload' ))); $router->addRoute('embed_v1_member_projectscomments', new Zend_Controller_Router_Route('/embed/v1/comments/:id', array( 'module' => 'default', 'controller' => 'embedv1', 'action' => 'comments' ))); $router->addRoute('embed_v1_member_projectdetail', new Zend_Controller_Router_Route('/embed/v1/project/:projectid', array( 'module' => 'default', 'controller' => 'embedv1', 'action' => 'projectdetail' ))); $router->addRoute('clones', new Zend_Controller_Router_Route('/clones', array( 'module' => 'default', 'controller' => 'credits', 'action' => 'index' ))); $cache->save($router, 'ProjectRouter', array('router'), 14400); return $router; } /** * @throws Zend_Cache_Exception * @throws Zend_Exception * @throws exception */ protected function _initCss() { if (APPLICATION_ENV != "development" && APPLICATION_ENV != "staging") { return; } $appConfig = $this->getResource('config'); if ((boolean)$appConfig->settings->noLESScompile === true) { return; } $sLess = realpath(APPLICATION_PATH . '/../httpdocs/theme/flatui/less/stylesheet.less'); $sCss = realpath(APPLICATION_PATH . '/../httpdocs/theme/flatui/css/stylesheet.css'); /** * @var Zend_Cache_Core $cache */ $cache = Zend_Registry::get('cache'); if (md5_file($sLess) !== $cache->load('md5Less')) { require_once APPLICATION_PATH . "/../library/lessphp/lessc.inc.php"; $oLessc = new lessc($sLess); $oLessc->setFormatter('compressed'); file_put_contents($sCss, $oLessc->parse()); $cache->save(md5_file($sLess), 'md5Less'); } } protected function _initGlobalApplicationVars() { $modelDomainConfig = new Default_Model_DbTable_ConfigStore(); Zend_Registry::set('application_store_category_list', $modelDomainConfig->fetchAllStoresAndCategories()); Zend_Registry::set('application_store_config_list', $modelDomainConfig->fetchAllStoresConfigArray()); Zend_Registry::set('application_store_config_id_list', $modelDomainConfig->fetchAllStoresConfigByIdArray()); } /** * @throws Zend_Application_Bootstrap_Exception */ protected function _initStoreDependentVars() { /** @var $front Zend_Controller_Front */ $front = $this->bootstrap('frontController')->getResource('frontController'); $front->registerPlugin(new Default_Plugin_InitGlobalStoreVars()); } } \ No newline at end of file diff --git a/application/modules/default/models/ConfigStore.php b/application/modules/default/models/ConfigStore.php index bcf9861cb..e1cb8d37c 100755 --- a/application/modules/default/models/ConfigStore.php +++ b/application/modules/default/models/ConfigStore.php @@ -1,104 +1,106 @@ . * * Created: 13.09.2017 */ class Default_Model_ConfigStore { /** * @inheritDoc */ public $store_id; public $host; public $name; public $config_id_name; public $mapping_id_name; public $order; public $is_client; public $google_id; public $piwik_id; public $package_type; public $cross_domain_login; public $is_show_title; public $is_show_home; public $is_show_git_projects; public $layout_home; public $layout_explore; public $layout_pagedetail; public $layout; public $render_view_postfix; + public $stay_in_context; public $created_at; public $changed_at; public $deleted_at; public function __construct($storeHostName) { $storeConfigArray = Zend_Registry::get('application_store_config_list'); if (isset($storeConfigArray[$storeHostName])) { $storeConfig = $storeConfigArray[$storeHostName]; $this->store_id = $storeConfig['store_id']; $this->host = $storeConfig['host']; $this->name = $storeConfig['name']; $this->config_id_name = $storeConfig['config_id_name']; $this->mapping_id_name = $storeConfig['mapping_id_name']; $this->order = $storeConfig['order']; $this->is_client = $storeConfig['is_client']; $this->google_id = $storeConfig['google_id']; $this->piwik_id = $storeConfig['piwik_id']; $this->package_type = $storeConfig['package_type']; $this->cross_domain_login = $storeConfig['cross_domain_login']; $this->is_show_title = $storeConfig['is_show_title']; $this->is_show_home = $storeConfig['is_show_home']; $this->is_show_git_projects = $storeConfig['is_show_git_projects']; $this->layout_home = $storeConfig['layout_home']; $this->layout_explore = $storeConfig['layout_explore']; $this->layout_pagedetail = $storeConfig['layout_pagedetail']; $this->layout = $storeConfig['layout']; $this->render_view_postfix = $storeConfig['render_view_postfix']; + $this->stay_in_context = $storeConfig['stay_in_context']; $this->created_at = $storeConfig['created_at']; $this->changed_at = $storeConfig['changed_at']; $this->deleted_at = $storeConfig['deleted_at']; } else { Zend_Registry::get('logger')->warn(__METHOD__ . '(' . __LINE__ . ') - ' . $host . ' :: no domain config context configured') ; } } /** * @return bool */ public function isShowHomepage() { return $this->is_show_home == 1 ? true : false; } /** * @return bool */ public function isRenderReact() { return $this->render_view_postfix == 'react' ? true : false; } } diff --git a/application/modules/default/models/DbTable/ProjectCategory.php b/application/modules/default/models/DbTable/ProjectCategory.php index 2f05413c4..04da2fc37 100644 --- a/application/modules/default/models/DbTable/ProjectCategory.php +++ b/application/modules/default/models/DbTable/ProjectCategory.php @@ -1,1656 +1,1665 @@ . **/ class Default_Model_DbTable_ProjectCategory extends Local_Model_Table { const CATEGORY_ACTIVE = 1; const CATEGORY_INACTIVE = 0; const CATEGORY_NOT_DELETED = 0; const CATEGORY_DELETED = 1; const ORDERED_TITLE = 'title'; const ORDERED_ID = 'project_category_id'; const ORDERED_HIERARCHIC = 'lft'; protected $_keyColumnsForRow = array('project_category_id'); protected $_key = 'project_category_id'; /** * @var string */ protected $_name = "project_category"; /** * @var array */ protected $_dependentTables = array('Default_Model_DbTable_Project'); /** * @var array */ protected $_referenceMap = array( 'Category' => array( 'columns' => 'project_category_id', 'refTableClass' => 'Default_Model_Project', 'refColumns' => 'project_category_id' ) ); /** @var Zend_Cache_Core */ protected $cache; /** * @inheritDoc */ public function init() { parent::init(); // TODO: Change the autogenerated stub $this->cache = Zend_Registry::get('cache'); } /** * @return array * @deprecated */ public function getSelectList() { $selectArr = $this->_db->fetchAll('SELECT `project_category_id`, `title` FROM `project_category` WHERE `is_active`=1 AND `is_deleted`=0 ORDER BY `orderPos`'); $arrayModified = array(); $arrayModified[0] = "ProjectAddFormCatSelect"; foreach ($selectArr as $item) { $arrayModified[$item['project_category_id']] = stripslashes($item['title']); } return $arrayModified; } /** * @return array * @deprecated */ public function getInternSelectList() { $selectArr = $this->_db->fetchAll('SELECT `project_category_id`, `title` FROM `project_category` WHERE `is_deleted`=0 ORDER BY `orderPos`'); $arrayModified = array(); $arrayModified[0] = "ProjectAddFormCatSelect"; foreach ($selectArr as $item) { $arrayModified[$item['project_category_id']] = stripslashes($item['title']); } return $arrayModified; } /** * @param $status * @param $id * */ public function setStatus($status, $id) { $updateValues = array( 'is_active' => $status, 'changed_at' => new Zend_Db_Expr('Now()') ); $this->update($updateValues, 'project_category_id=' . $id); } /** * @param $id * */ public function setDelete($id) { $updateValues = array( 'is_active' => 0, 'is_deleted' => 1, 'deleted_at' => new Zend_Db_Expr('Now()') ); $this->update($updateValues, 'project_category_id=' . $id); } /** * @return Zend_Db_Table_Rowset_Abstract * @throws Zend_Cache_Exception * @deprecated */ public function fetchAllActive() { $cache = $this->cache; $cacheName = __FUNCTION__; if (!($categories = $cache->load($cacheName))) { $q = $this->select()->where('is_active = ?', 1)->where('is_deleted = ?', 0)->order('orderPos'); $categories = $this->fetchAll($q); $cache->save($categories, $cacheName); } return $categories; } /** * @param int|array $nodeId * * @return array * @throws Zend_Cache_Exception * @throws Zend_Db_Statement_Exception */ public function fetchActive($nodeId) { $str = is_array($nodeId) ? implode(',', $nodeId) : $nodeId; /** @var Zend_Cache_Core $cache */ $cache = $this->cache; $cacheName = __FUNCTION__ . '_' . md5($str); if (false === ($active = $cache->load($cacheName))) { $inQuery = '?'; if (is_array($nodeId)) { $inQuery = implode(',', array_fill(0, count($nodeId), '?')); } $sql = "SELECT *, (SELECT `project_category_id` FROM `project_category` AS `t2` WHERE `t2`.`lft` < `node`.`lft` AND `t2`.`rgt` > `node`.`rgt` AND `t2`.`is_deleted` = 0 ORDER BY `t2`.`rgt`-`node`.`rgt` ASC LIMIT 1) AS `parent` FROM {$this->_name} as node WHERE project_category_id IN ($inQuery) AND is_active = 1 "; $active = $this->_db->query($sql, $nodeId)->fetchAll(); if (count($active) == 0) { $active = array(); } $cache->save($active, $cacheName, array(), 3600); } return $active; } /** * @param int|array $nodeId * * @return array * @throws Zend_Db_Statement_Exception */ public function fetchActiveOrder($nodeId) { $inQuery = '?'; if (is_array($nodeId)) { $inQuery = implode(',', array_fill(0, count($nodeId), '?')); } $sql = "SELECT *, (SELECT `project_category_id` FROM `project_category` AS `t2` WHERE `t2`.`lft` < `node`.`lft` AND `t2`.`rgt` > `node`.`rgt` AND `t2`.`is_deleted` = 0 ORDER BY `t2`.`rgt`-`node`.`rgt`ASC LIMIT 1) AS `parent` FROM {$this->_name} as node WHERE project_category_id IN ($inQuery) AND is_active = 1 "; $active = $this->_db->query($sql, $nodeId)->fetchAll(); if (count($active)) { return $active; } else { return array(); } } /* ------------------------ */ /* New Nested Set Functions */ /* ------------------------ */ public function setCategoryDeleted($id, $updateChildren = true) { $node = $this->findCategory($id); if (count($node->toArray()) == 0) { return false; } $this->_db->beginTransaction(); try { $this->_db->query("UPDATE {$this->_name} SET is_active = 0, is_deleted = 1, deleted_at = :del_date WHERE project_category_id = :cat_id;", array('cat_id' => $id, 'del_date'=>new Zend_Db_Expr('Now()'))); if ($updateChildren) { $this->_db->query("UPDATE {$this->_name} SET is_active = 0, is_deleted = 1, deleted_at = :del_date WHERE lft > :parent_lft AND rgt < :parent_rgt;", array('del_date'=>new Zend_Db_Expr('Now()'), 'parent_lft' => $node->lft, 'parent_rgt' => $node->rgt)); } $this->_db->commit(); } catch (Exception $e) { $this->_db->rollBack(); Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); } return $node; } /** * @param $title * * @return null|Zend_Db_Table_Row_Abstract * @throws Zend_Exception */ public function appendNewElement($title) { $root = $this->fetchRoot(); $data['rgt'] = $root->rgt - 1; $data['title'] = $title; return $this->addNewElement($data); } /** * @return null|Zend_Db_Table_Row_Abstract */ public function fetchRoot() { return $this->fetchRow('`lft` = 0'); } /** * @param array $data * * @return null|Zend_Db_Table_Row_Abstract * @throws Zend_Exception */ public function addNewElement($data) { $this->_db->beginTransaction(); try { $this->_db->query("UPDATE {$this->_name} SET rgt = rgt + 2 WHERE rgt > :param_right;", array('param_right' => $data['rgt'])); $this->_db->query("UPDATE {$this->_name} SET lft = lft + 2 WHERE lft > :param_right;", array('param_right' => $data['rgt'])); $this->_db->query(" INSERT INTO project_category (`lft`, `rgt`, `title`, `is_active`, `name_legacy`, `xdg_type`, `dl_pling_factor`, `show_description`, `source_required`) VALUES (:param_right + 1, :param_right + 2, :param_title, :param_status, :param_legacy, :param_xgd, :param_pling, :param_show_desc, :param_source);", array( 'param_right' => $data['rgt'], 'param_title' => $data['title'], 'param_status' => $data['is_active'], 'param_legacy' => $data['name_legacy'], 'param_xgd' => $data['xdg_type'], 'param_show_desc' => $data['show_description'], 'param_source' => $data['source_required'], 'param_pling' => $data['dl_pling_factor'] )); $this->_db->commit(); } catch (Exception $e) { $this->_db->rollBack(); Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); } return $this->fetchRow('lft = ' . ($data['rgt'] + 1)); } /** * @param $cat_id * * @return array */ public function fetchTreeForJTable($cat_id) { $resultRows = $this->fetchTree(false, true, 5); $resultForSelect = array(); foreach ($resultRows as $row) { if (($row['project_category_id'] == $cat_id) OR ($row['parent'] == $cat_id)) { continue; } $resultForSelect[] = array('DisplayText' => $row['title_show'], 'Value' => $row['project_category_id']); } return $resultForSelect; } /** * @param bool $isActive * @param bool $withRoot * @param int $depth * * @return array * @internal param int $pageSize * @internal param int $startIndex * @internal param bool $clearCache */ public function fetchTree( $isActive = false, $withRoot = true, $depth = null ) { $sqlActive = $isActive == true ? " parent_active = 1 AND pc.is_active = 1" : ''; $sqlRoot = $withRoot == true ? "(pc.lft BETWEEN pc2.lft AND pc2.rgt)" : "(pc.lft BETWEEN pc2.lft AND pc2.rgt) AND pc2.lft > 0"; $sqlDepth = is_null($depth) == true ? '' : " AND depth <= " . (int)$depth; $sqlHaving = $sqlActive || $sqlDepth ? "HAVING {$sqlActive} {$sqlDepth}" : ''; $sql = " SELECT `pc`.`project_category_id`, `pc`.`lft`, `pc`.`rgt`, `pc`.`title`, `pc`.`name_legacy`, `pc`.`is_active`, `pc`.`orderPos`, `pc`.`xdg_type`, `pc`.`dl_pling_factor`, `pc`.`show_description`, `pc`.`source_required`, MIN(`pc2`.`is_active`) AS `parent_active`, concat(repeat('  ',count(`pc`.`lft`) - 1), `pc`.`title`) AS `title_show`, concat(repeat('  ',count(`pc`.`lft`) - 1), IF(LENGTH(TRIM(`pc`.`name_legacy`))>0,`pc`.`name_legacy`,`pc`.`title`)) AS `title_legacy`, count(`pc`.`lft`) - 1 AS `depth`, GROUP_CONCAT(`pc2`.`project_category_id` ORDER BY `pc2`.`lft`) AS `ancestor_id_path`, GROUP_CONCAT(`pc2`.`title` ORDER BY `pc2`.`lft` SEPARATOR ' | ') AS `ancestor_path`, GROUP_CONCAT(IF(LENGTH(TRIM(`pc2`.`name_legacy`))>0,`pc2`.`name_legacy`,`pc2`.`title`) ORDER BY `pc2`.`lft` SEPARATOR ' | ') AS `ancestor_path_legacy` FROM `project_category` AS `pc` JOIN `project_category` AS `pc2` ON {$sqlRoot} GROUP BY pc.lft {$sqlHaving} ORDER BY pc.lft "; $tree = $this->_db->fetchAll($sql); return $tree; } /** * @param bool $isActive * @param bool $withRoot * @param int $depth * * @return array * @internal param int $pageSize * @internal param int $startIndex * @internal param bool $clearCache */ public function fetchTreeWithParentId( $isActive = true, $depth = null ) { $sqlActive = $isActive == true ? " parent_active = 1 AND pc.is_active = 1" : ''; $sqlDepth = is_null($depth) == true ? '' : " AND depth <= " . (int)$depth; $sqlHaving = $sqlActive || $sqlDepth ? "HAVING {$sqlActive} {$sqlDepth}" : ''; $sql = " SELECT `pc`.`project_category_id`, `pc`.`lft`, `pc`.`rgt`, `pc`.`title`, `pc`.`name_legacy`, `pc`.`is_active`, `pc`.`orderPos`, `pc`.`xdg_type`, `pc`.`dl_pling_factor`, `pc`.`show_description`, `pc`.`source_required`, MIN(`pc2`.`is_active`) AS `parent_active`, concat(repeat('  ',count(`pc`.`lft`) - 1), `pc`.`title`) AS `title_show`, concat(repeat('  ',count(`pc`.`lft`) - 1), IF(LENGTH(TRIM(`pc`.`name_legacy`))>0,`pc`.`name_legacy`,`pc`.`title`)) AS `title_legacy`, count(`pc`.`lft`) - 1 AS `depth`, GROUP_CONCAT(`pc2`.`project_category_id` ORDER BY `pc2`.`lft`) AS `ancestor_id_path`, GROUP_CONCAT(`pc2`.`title` ORDER BY `pc2`.`lft` SEPARATOR ' | ') AS `ancestor_path`, GROUP_CONCAT(IF(LENGTH(TRIM(`pc2`.`name_legacy`))>0,`pc2`.`name_legacy`,`pc2`.`title`) ORDER BY `pc2`.`lft` SEPARATOR ' | ') AS `ancestor_path_legacy`, SUBSTRING_INDEX( GROUP_CONCAT(`pc2`.`project_category_id` ORDER BY `pc2`.`lft`), ',', -1) AS `parent` FROM `project_category` AS `pc` JOIN `project_category` AS `pc2` ON (`pc`.`lft` BETWEEN `pc2`.`lft` AND `pc2`.`rgt`) AND `pc2`.`project_category_id` <> `pc`.`project_category_id` GROUP BY `pc`.`lft` {$sqlHaving} ORDER BY pc.lft "; $tree = $this->_db->fetchAll($sql); return $tree; } /** * @param bool $isActive * @param bool $withRoot * @param int $depth * * @return array * @internal param int $pageSize * @internal param int $startIndex * @internal param bool $clearCache */ public function fetchTreeWithParentIdAndTags( $isActive = true, $depth = null ) { $sqlActive = $isActive == true ? " parent_active = 1 AND pc.is_active = 1" : ''; $sqlDepth = is_null($depth) == true ? '' : " AND depth <= " . (int)$depth; $sqlHaving = $sqlActive || $sqlDepth ? "HAVING {$sqlActive} {$sqlDepth}" : ''; $sql = " SELECT `pc`.`project_category_id`, `pc`.`lft`, `pc`.`rgt`, `pc`.`title`, `pc`.`name_legacy`, `pc`.`is_active`, `pc`.`orderPos`, `pc`.`xdg_type`, `pc`.`dl_pling_factor`, `pc`.`show_description`, `pc`.`source_required`, MIN(`pc2`.`is_active`) AS `parent_active`, concat(repeat('  ',count(`pc`.`lft`) - 1), `pc`.`title`) AS `title_show`, concat(repeat('  ',count(`pc`.`lft`) - 1), IF(LENGTH(TRIM(`pc`.`name_legacy`))>0,`pc`.`name_legacy`,`pc`.`title`)) AS `title_legacy`, count(`pc`.`lft`) - 1 AS `depth`, GROUP_CONCAT(`pc2`.`project_category_id` ORDER BY `pc2`.`lft`) AS `ancestor_id_path`, GROUP_CONCAT(`pc2`.`title` ORDER BY `pc2`.`lft` SEPARATOR ' | ') AS `ancestor_path`, GROUP_CONCAT(IF(LENGTH(TRIM(`pc2`.`name_legacy`))>0,`pc2`.`name_legacy`,`pc2`.`title`) ORDER BY `pc2`.`lft` SEPARATOR ' | ') AS `ancestor_path_legacy`, SUBSTRING_INDEX( GROUP_CONCAT(`pc2`.`project_category_id` ORDER BY `pc2`.`lft`), ',', -1) AS `parent`, (SELECT GROUP_CONCAT(`tag`.`tag_name`) FROM `category_tag`,`tag` WHERE `tag`.`tag_id` = `category_tag`.`tag_id` AND `category_tag`.`category_id` = `pc`.`project_category_id` GROUP BY `category_tag`.`category_id`) AS `tags_name`, (SELECT GROUP_CONCAT(`tag`.`tag_id`) FROM `category_tag`,`tag` WHERE `tag`.`tag_id` = `category_tag`.`tag_id` AND `category_tag`.`category_id` = `pc`.`project_category_id` GROUP BY `category_tag`.`category_id`) AS `tags_id` FROM `project_category` AS `pc` JOIN `project_category` AS `pc2` ON (`pc`.`lft` BETWEEN `pc2`.`lft` AND `pc2`.`rgt`) AND `pc2`.`project_category_id` <> `pc`.`project_category_id` GROUP BY `pc`.`lft` {$sqlHaving} ORDER BY pc.lft "; $tree = $this->_db->fetchAll($sql); return $tree; } /** * @param bool $isActive * @param bool $withRoot * @param int $depth * * @return array * @internal param int $pageSize * @internal param int $startIndex * @internal param bool $clearCache */ public function fetchTreeWithParentIdAndTagGroups( $isActive = true, $depth = null ) { $sqlActive = $isActive == true ? " parent_active = 1 AND pc.is_active = 1" : ''; $sqlDepth = is_null($depth) == true ? '' : " AND depth <= " . (int)$depth; $sqlHaving = $sqlActive || $sqlDepth ? "HAVING {$sqlActive} {$sqlDepth}" : ''; $sql = " SELECT `pc`.`project_category_id`, `pc`.`lft`, `pc`.`rgt`, `pc`.`title`, `pc`.`name_legacy`, `pc`.`is_active`, `pc`.`orderPos`, `pc`.`xdg_type`, `pc`.`dl_pling_factor`, `pc`.`show_description`, `pc`.`source_required`, MIN(`pc2`.`is_active`) AS `parent_active`, concat(repeat('  ',count(`pc`.`lft`) - 1), `pc`.`title`) AS `title_show`, concat(repeat('  ',count(`pc`.`lft`) - 1), IF(LENGTH(TRIM(`pc`.`name_legacy`))>0,`pc`.`name_legacy`,`pc`.`title`)) AS `title_legacy`, count(`pc`.`lft`) - 1 AS `depth`, GROUP_CONCAT(`pc2`.`project_category_id` ORDER BY `pc2`.`lft`) AS `ancestor_id_path`, GROUP_CONCAT(`pc2`.`title` ORDER BY `pc2`.`lft` SEPARATOR ' | ') AS `ancestor_path`, GROUP_CONCAT(IF(LENGTH(TRIM(`pc2`.`name_legacy`))>0,`pc2`.`name_legacy`,`pc2`.`title`) ORDER BY `pc2`.`lft` SEPARATOR ' | ') AS `ancestor_path_legacy`, SUBSTRING_INDEX( GROUP_CONCAT(`pc2`.`project_category_id` ORDER BY `pc2`.`lft`), ',', -1) AS `parent`, (SELECT GROUP_CONCAT(`tag_group`.`group_name`) FROM `category_tag_group`,`tag_group` WHERE `tag_group`.`group_id` = `category_tag_group`.`tag_group_id` AND `category_tag_group`.`category_id` = `pc`.`project_category_id` GROUP BY `category_tag_group`.`category_id`) AS `tag_group_name`, (SELECT GROUP_CONCAT(`tag_group`.`group_id`) FROM `category_tag_group`,`tag_group` WHERE `tag_group`.`group_id` = `category_tag_group`.`tag_group_id` AND `category_tag_group`.`category_id` = `pc`.`project_category_id` GROUP BY `category_tag_group`.`category_id`) AS `tag_group_id` FROM `project_category` AS `pc` JOIN `project_category` AS `pc2` ON (`pc`.`lft` BETWEEN `pc2`.`lft` AND `pc2`.`rgt`) AND `pc2`.`project_category_id` <> `pc`.`project_category_id` GROUP BY `pc`.`lft` {$sqlHaving} ORDER BY pc.lft "; $tree = $this->_db->fetchAll($sql); return $tree; } /** * @param $cat_id * * @return array */ public function fetchTreeForJTableStores($cat_id) { $sql = " SELECT pc.project_category_id, pc.lft, pc.rgt, pc.title, pc.name_legacy, pc.is_active, pc.orderPos, pc.xdg_type, pc.dl_pling_factor, pc.show_description, pc.source_required, MIN(pc2.is_active) AS parent_active, concat(repeat('  ',count(pc.lft) - 1), pc.title) AS title_show, concat(repeat('  ',count(pc.lft) - 1), IF(LENGTH(TRIM(pc.name_legacy))>0,pc.name_legacy,pc.title)) AS title_legacy, count(pc.lft) - 1 AS depth, GROUP_CONCAT(pc2.project_category_id ORDER BY pc2.lft) AS ancestor_id_path, GROUP_CONCAT(pc2.title ORDER BY pc2.lft SEPARATOR ' | ') AS ancestor_path, GROUP_CONCAT(IF(LENGTH(TRIM(pc2.name_legacy))>0,pc2.name_legacy,pc2.title) ORDER BY pc2.lft SEPARATOR ' | ') AS ancestor_path_legacy, SUBSTRING_INDEX( GROUP_CONCAT(pc2.project_category_id ORDER BY pc2.lft), ',', -1) AS parent FROM project_category AS pc JOIN project_category AS pc2 ON (pc.lft BETWEEN pc2.lft AND pc2.rgt) AND (IF(pc.project_category_id <> 34,pc2.project_category_id <> pc.project_category_id,true)) GROUP BY pc.lft HAVING parent_active = 1 AND pc.is_active = 1 ORDER BY pc.lft "; $resultRows = $this->_db->fetchAll($sql); $resultForSelect = array(); foreach ($resultRows as $row) { if (($row['project_category_id'] == $cat_id) OR ($row['parent'] == $cat_id)) { continue; } $resultForSelect[] = array('DisplayText' => $row['title_show'], 'Value' => $row['project_category_id']); } return $resultForSelect; } /** * @param $cat_id * * @return array */ public function fetchTreeForCategoryStores($cat_id) { $sql = " SELECT pc.project_category_id, pc.lft, pc.rgt, pc.title, pc.is_active, MIN(pc2.is_active) AS parent_active, count(pc.lft) - 1 AS depth, SUBSTRING_INDEX( GROUP_CONCAT(pc2.project_category_id ORDER BY pc2.lft), ',', -1) AS parent FROM project_category AS pc JOIN project_category AS pc2 ON (pc.lft BETWEEN pc2.lft AND pc2.rgt) AND (IF(pc.project_category_id <> 34,pc2.project_category_id <> pc.project_category_id,true)) GROUP BY pc.lft HAVING parent_active = 1 AND pc.is_active = 1 ORDER BY pc.lft "; $resultRows = $this->_db->fetchAll($sql); $resultForSelect = array(); foreach ($resultRows as $row) { if (($row['project_category_id'] == $cat_id) OR ($row['parent'] == $cat_id)) { continue; } $resultForSelect[] = array('DisplayText' => $row['title'], 'Value' => $row['project_category_id']); } return $resultForSelect; } /** * @param array $node * @param int $newLeftPosition * * @return bool * @throws Zend_Exception * @deprecated use moveTo instead */ public function moveElement($node, $newLeftPosition) { $space = $node['rgt'] - $node['lft'] + 1; $distance = $newLeftPosition - $node['lft']; $srcPosition = $node['lft']; //for backwards movement, we have to fix some values if ($distance < 0) { $distance -= $space; $srcPosition += $space; } $this->_db->beginTransaction(); try { // create space for subtree $this->_db->query("UPDATE {$this->_name} SET rgt = rgt + :space WHERE rgt >= :newLeftPosition;", array('space' => $space, 'newLeftPosition' => $newLeftPosition)); $this->_db->query("UPDATE {$this->_name} SET lft = lft + :space WHERE lft >= :newLeftPosition;", array('space' => $space, 'newLeftPosition' => $newLeftPosition)); // move tree $this->_db->query("UPDATE {$this->_name} SET lft = lft + :distance, rgt = rgt + :distance WHERE lft >= :srcPosition AND rgt < :srcPosition + :space;", array('distance' => $distance, 'srcPosition' => $srcPosition, 'space' => $space)); // remove old space $this->_db->query("UPDATE {$this->_name} SET rgt = rgt - :space WHERE rgt > :srcPosition;", array('space' => $space, 'srcPosition' => $srcPosition)); $this->_db->query("UPDATE {$this->_name} SET lft = lft - :space WHERE lft >= :srcPosition;", array('space' => $space, 'srcPosition' => $srcPosition)); // move it $this->_db->commit(); } catch (Exception $e) { $this->_db->rollBack(); Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); return false; } return true; } public function findAncestor($data) { $resultRow = $this->fetchRow("rgt = {$data['lft']} - 1"); if (($resultRow->rgt - $resultRow->lft) > 1) { $resultRow = $this->fetchRow("lft = {$resultRow->lft} - 2"); } return $resultRow; } /** * @param $data * * @return array|null * @throws Zend_Db_Statement_Exception * @throws Zend_Db_Table_Exception */ public function findPreviousSibling($data) { $parent = $this->fetchParentForId($data); $parent_category_id = $parent->project_category_id; $sql = "SELECT node.project_category_id, node.lft, node.rgt, node.title, (SELECT `project_category_id` FROM `project_category` AS `t2` WHERE `t2`.`lft` < `node`.`lft` AND `t2`.`rgt` > `node`.`rgt` ORDER BY `t2`.`rgt`-`node`.`rgt`ASC LIMIT 1) AS `parent_category_id` FROM project_category AS node, project_category AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt GROUP BY node.project_category_id HAVING parent_category_id = :parent_category_id ORDER BY node.lft"; $siblings = $this->_db->query($sql, array('parent_category_id' => $parent_category_id))->fetchAll(); $resultRow = null; $bufferRow = null; foreach ($siblings as $row) { if ($row['project_category_id'] != $data['project_category_id']) { $bufferRow = $row; continue; } $resultRow = $bufferRow; } return $resultRow; } /** * @param $data * * @return Zend_Db_Table_Row_Abstract * @throws Zend_Db_Statement_Exception * @throws Zend_Db_Table_Exception */ public function fetchParentForId($data) { $sql = " SELECT `title`, (SELECT `project_category_id` FROM `project_category` AS `t2` WHERE `t2`.`lft` < `node`.`lft` AND `t2`.`rgt` > `node`.`rgt` ORDER BY `t2`.`rgt`-`node`.`rgt`ASC LIMIT 1) AS `parent` FROM `project_category` AS `node` WHERE `project_category_id` = :category_id ORDER BY (`rgt`-`lft`) DESC "; $resultRow = $this->_db->query($sql, array('category_id' => $data['project_category_id']))->fetch(); return $this->find($resultRow['parent'])->current(); } /** * @param $data * * @return array|null * @throws Zend_Db_Statement_Exception * @throws Zend_Db_Table_Exception */ public function findNextSibling($data) { $parent = $this->fetchParentForId($data); $parent_category_id = $parent->project_category_id; $sql = "SELECT node.project_category_id, node.lft, node.rgt, node.title, (SELECT `project_category_id` FROM `project_category` AS `t2` WHERE `t2`.`lft` < `node`.`lft` AND `t2`.`rgt` > `node`.`rgt` ORDER BY `t2`.`rgt`-`node`.`rgt`ASC LIMIT 1) AS `parent_category_id` FROM project_category AS node, project_category AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt GROUP BY node.project_category_id HAVING parent_category_id = :parent_category_id ORDER BY node.lft"; $siblings = $this->_db->query($sql, array('parent_category_id' => $parent_category_id))->fetchAll(); $resultRow = null; $found = false; foreach ($siblings as $row) { if ($found == true) { $resultRow = $row; break; } if ($row['project_category_id'] == $data['project_category_id']) { $found = true; continue; } } return $resultRow; } /** * @param $data * * @return null|Zend_Db_Table_Row_Abstract */ public function findPreviousElement($data) { $resultRow = $this->fetchRow("rgt = {$data['lft']} - 1"); if (($resultRow->rgt - $resultRow->lft) > 1) { $resultRow = $this->fetchRow("lft = {$resultRow->rgt} - 2"); } return $resultRow; } /** * @param $data * * @return null|Zend_Db_Table_Row_Abstract */ public function findNextElement($data) { $resultRow = $this->fetchRow("lft = {$data['rgt']} + 1"); if (($resultRow->rgt - $resultRow->lft) > 1) { $resultRow = $this->fetchRow("lft = {$resultRow->lft} + 2"); } return $resultRow; } /** * @param string|array $nodeId * @param array $options * * @return array * @throws Zend_Exception */ public function fetchChildTree($nodeId, $options = array()) { $clearCache = false; if (isset($options['clearCache'])) { $clearCache = $options['clearCache']; unset($options['clearCache']); } /** @var Zend_Cache_Core $cache */ $cache = $this->cache; $cacheName = __FUNCTION__ . '_' . md5(serialize($nodeId) . serialize($options)); if ($clearCache) { $cache->remove($cacheName); } if (!($tree = $cache->load($cacheName))) { $extSqlWhereActive = " AND o.is_active = 1"; if (isset($options['isActive']) AND $options['isActive'] == false) { $extSqlWhereActive = ''; } $extSqlHavingDepth = ''; if (isset($options['depth'])) { $extSqlHavingDepth = " HAVING depth <= " . (int)$options['depth']; } $inQuery = '?'; if (is_array($nodeId)) { $inQuery = implode(',', array_fill(0, count($nodeId), '?')); } $sql = "SELECT `o`.*, COUNT(`p`.`project_category_id`)-1 AS `depth`, CONCAT( REPEAT( '  ', (COUNT(`p`.`title`) - 1) ), `o`.`title`) AS `title_show`, `pc`.`product_counter` FROM `project_category` AS `n` INNER JOIN `project_category` AS `p` INNER JOIN `project_category` AS `o` LEFT JOIN (SELECT `project`.`project_category_id`, count(`project`.`project_category_id`) AS `product_counter` FROM `project` WHERE `project`.`status` = 100 AND `project`.`type_id` = 1 GROUP BY `project`.`project_category_id`) AS `pc` ON `pc`.`project_category_id` = `o`.`project_category_id` WHERE `o`.`lft` BETWEEN `p`.`lft` AND `p`.`rgt` AND `o`.`lft` BETWEEN `n`.`lft` AND `n`.`rgt` AND `n`.`project_category_id` IN ({$inQuery}) AND `o`.`lft` > `p`.`lft` AND `o`.`lft` > `n`.`lft` {$extSqlWhereActive} GROUP BY o.lft {$extSqlHavingDepth} ORDER BY o.lft; ; "; $tree = $this->_db->query($sql, $nodeId)->fetchAll(); $cache->save($tree, $cacheName); } return $tree; } /** * @param int|array $nodeId * @param bool $isActive * * @return array Set of subnodes * @throws Zend_Cache_Exception * @throws Zend_Db_Statement_Exception */ public function fetchChildElements($nodeId, $isActive = true) { if (is_null($nodeId) OR $nodeId == '') { return array(); } /** @var Zend_Cache_Core $cache */ $cache = $this->cache; $cacheName = __FUNCTION__ . '_' . md5(serialize($nodeId) . (int)$isActive); if (($children = $cache->load($cacheName))) { return $children; } $inQuery = '?'; if (is_array($nodeId)) { $inQuery = implode(',', array_fill(0, count($nodeId), '?')); } $whereActive = $isActive == true ? ' AND o.is_active = 1' : ''; $sql = " SELECT o.*, COUNT(p.project_category_id)-2 AS depth FROM project_category AS n, project_category AS p, project_category AS o WHERE o.lft BETWEEN p.lft AND p.rgt AND o.lft BETWEEN n.lft AND n.rgt AND n.project_category_id IN ({$inQuery}) {$whereActive} GROUP BY o.lft HAVING depth > 0 ORDER BY o.lft; "; $children = $this->_db->query($sql, $nodeId)->fetchAll(); $cache->save($children, $cacheName); if (count($children)) { return $children; } else { return array(); } } /** * @param int|array $nodeId * @param bool $isActive * * @return array Set of subnodes * @throws Zend_Cache_Exception * @throws Zend_Db_Statement_Exception */ public function fetchChildIds($nodeId, $isActive = true) { if (empty($nodeId) OR $nodeId == '') { return array(); } /** @var Zend_Cache_Core $cache */ $cache = $this->cache; $cacheName = __FUNCTION__ . '_' . md5(serialize($nodeId) . (int)$isActive); if (false !== ($children = $cache->load($cacheName))) { return $children; } $inQuery = '?'; if (is_array($nodeId)) { $inQuery = implode(',', array_fill(0, count($nodeId), '?')); } $whereActive = $isActive == true ? ' AND o.is_active = 1' : ''; $sql = " SELECT o.project_category_id FROM project_category AS n, project_category AS p, project_category AS o WHERE o.lft BETWEEN p.lft AND p.rgt AND o.lft BETWEEN n.lft AND n.rgt AND n.project_category_id IN ({$inQuery}) {$whereActive} GROUP BY o.lft HAVING COUNT(p.project_category_id)-2 > 0 ORDER BY o.lft; "; if (APPLICATION_ENV == "development") { Zend_Registry::get('logger')->debug(__METHOD__ . ' - ' . $sql . ' - ' . json_encode($nodeId)); } $children = $this->_db->query($sql, $nodeId)->fetchAll(); if (count($children)) { $result = $this->flattenArray($children); $result = $this->removeUnnecessaryValues($nodeId, $result); $cache->save($result, $cacheName); return $result; } else { return array(); } } /** * * @flatten multi-dimensional array * * @param array $array * * @return array * */ private function flattenArray(array $array) { $ret_array = array(); foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($array)) as $value) { $ret_array[] = $value; } return $ret_array; } /** * @param array $nodeId * @param array $children * * @return array */ private function removeUnnecessaryValues($nodeId, $children) { $nodeId = is_array($nodeId) ? $nodeId : array($nodeId); return array_diff($children, $nodeId); } /** * @param $nodeId * @param string $orderBy * * @return array * @throws Zend_Db_Statement_Exception */ public function fetchImmediateChildrenIds($nodeId, $orderBy = self::ORDERED_HIERARCHIC) { $sql = " SELECT `node`.`project_category_id` FROM `project_category` AS `node` WHERE `node`.`is_active` = 1 HAVING (SELECT `parent`.`project_category_id` FROM `project_category` AS `parent` WHERE `parent`.`lft` < `node`.`lft` AND `parent`.`rgt` > `node`.`rgt` ORDER BY `parent`.`rgt`-`node`.`rgt` LIMIT 1) = ? ORDER BY `node`.`{$orderBy}`; "; $children = $this->_db->query($sql, $nodeId)->fetchAll(Zend_Db::FETCH_NUM); if (count($children)) { return $this->flattenArray($children); } else { return array(); } } /** * @param Zend_Db_Table_Row $first * @param Zend_Db_Table_Row $second * * @return \Zend_Db_Table_Row * @throws Zend_Exception * @deprecated */ public function switchElements($first, $second) { $bufferLeft = $first->lft; $bufferRight = $first->rgt; $this->_db->beginTransaction(); try { $this->_db->query("UPDATE {$this->_name} SET rgt = {$second->rgt} WHERE project_category_id = {$first->project_category_id};"); $this->_db->query("UPDATE {$this->_name} SET lft = {$second->lft} WHERE project_category_id = {$first->project_category_id};"); $this->_db->query("UPDATE {$this->_name} SET rgt = {$bufferRight} WHERE project_category_id = {$second->project_category_id};"); $this->_db->query("UPDATE {$this->_name} SET lft = {$bufferLeft} WHERE project_category_id = {$second->project_category_id};"); $this->_db->commit(); } catch (Exception $e) { $this->_db->rollBack(); Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); } $first->refresh(); return $first; } /** * @param int $returnAmount * @param int $fetchLimit * * @return array|false|mixed */ public function fetchMainCategories($returnAmount = 25, $fetchLimit = 25) { $categories = $this->fetchTree(true, false, 1); return array_slice($categories, 0, $returnAmount); } /** * @return array * @throws Zend_Cache_Exception * @throws Zend_Db_Statement_Exception */ public function fetchMainCatIdsOrdered() { /** @var Zend_Cache_Core $cache */ $cache = $this->cache; $cacheName = __FUNCTION__; if (($returnValue = $cache->load($cacheName))) { return $returnValue; } $sql = " SELECT `node`.`project_category_id` FROM `project_category` AS `node` INNER JOIN `project_category` AS `parent` WHERE `node`.`lft` BETWEEN `parent`.`lft` AND `parent`.`rgt` AND `node`.`is_active` = 1 AND `node`.`is_deleted` = 0 AND `node`.`lft` > 0 GROUP BY `node`.`project_category_id` HAVING (COUNT(`parent`.`title`) - 1) = 1 ORDER BY `node`.`orderPos`, `node`.`lft`; "; $result = $this->_db->query($sql)->fetchAll(Zend_Db::FETCH_NUM); if (count($result) > 0) { $returnValue = $this->flattenArray($result); $cache->save($returnValue, $cacheName, array(), 900); return $returnValue; } else { return array(); } } /** * @return array * @throws Zend_Db_Statement_Exception */ public function fetchMainCatsOrdered() { $sql = " SELECT node.project_category_id, node.title, node.lft, node.rgt FROM project_category AS node INNER JOIN project_category AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt AND node.is_active = 1 AND node.is_deleted = 0 AND node.lft > 0 GROUP BY node.project_category_id HAVING (COUNT(parent.title) - 1) = 1 ORDER BY node.orderPos, node.lft; "; $result = $this->_db->query($sql)->fetchAll(); if (count($result) > 0) { return $result; } else { return array(); } } /** * @param int $cat_id * @param string $orderBy * * @return array * @throws Zend_Db_Statement_Exception */ public function fetchSubCatIds($cat_id, $orderBy = self::ORDERED_HIERARCHIC) { $sql = " SELECT node.project_category_id FROM project_category AS node INNER JOIN project_category AS parent WHERE parent.project_category_id IN (:cat_id) -- AND node.lft BETWEEN parent.lft AND parent.rgt AND node.lft > parent.lft AND node.rgt < parent.rgt AND node.is_active = 1 AND node.is_deleted = 0 AND node.lft > 0 GROUP BY node.project_category_id ORDER BY node.`{$orderBy}` ; "; $result = $this->_db->query($sql, array('cat_id' => $cat_id))->fetchAll(Zend_Db::FETCH_NUM); if (count($result) > 0) { // array_shift($result); return $this->flattenArray($result); } else { return array(); } } /** * @param int $returnAmount * @param int $fetchLimit * * @return array */ public function fetchRandomCategories($returnAmount = 5, $fetchLimit = 25) { $categories = $this->fetchTree(true, false, 1); return $this->_array_random($categories, $returnAmount); } /** * @param array $categories * @param int $count * * @return array */ protected function _array_random($categories, $count = 1) { shuffle($categories); return array_slice($categories, 0, $count); } /** * @param int $currentNodeId * @param int $newParentNodeId * @param string $position * * @return bool * @throws Zend_Db_Statement_Exception * @throws Zend_Db_Table_Exception * @throws Zend_Exception */ public function moveToParent($currentNodeId, $newParentNodeId, $position = 'top') { if ($currentNodeId <= 0) { return false; } $currentNode = $this->fetchElement($currentNodeId); $currentParentNode = $this->fetchParentForId($currentNode); if ($newParentNodeId == $currentParentNode->project_category_id) { return false; } $newParentNode = $this->fetchElement($newParentNodeId); if ($position == 'top') { return $this->moveTo($currentNode, $newParentNode['lft'] + 1); } else { return $this->moveTo($currentNode, $newParentNode['rgt']); // move to bottom otherwise } } /** * @param int $nodeId * * @return array Returns Element as array or (if empty) an array with empty values * @throws Zend_Db_Table_Exception */ public function fetchElement($nodeId) { if (is_null($nodeId) OR $nodeId == '') { return $this->createRow(); } $currentNode = $this->find($nodeId)->current(); if ($currentNode === null) { $resultValue = $this->createRow()->toArray(); } else { $resultValue = $currentNode->toArray(); } return $resultValue; } /** * @param array $node complete node data * @param int $newLeftPosition new left position for the node * * @return bool * @throws Zend_Exception */ public function moveTo($node, $newLeftPosition) { $space = $node['rgt'] - $node['lft'] + 1; $distance = $newLeftPosition - $node['lft']; $srcPosition = $node['lft']; //for backwards movement, we have to fix some values if ($distance < 0) { $distance -= $space; $srcPosition += $space; } $this->_db->beginTransaction(); try { // create space for subtree $this->_db->query("UPDATE {$this->_name} SET lft = lft + :space WHERE lft >= :newLeftPosition;", array('space' => $space, 'newLeftPosition' => $newLeftPosition)); $this->_db->query("UPDATE {$this->_name} SET rgt = rgt + :space WHERE rgt >= :newLeftPosition;", array('space' => $space, 'newLeftPosition' => $newLeftPosition)); // move tree $this->_db->query("UPDATE {$this->_name} SET lft = lft + :distance, rgt = rgt + :distance WHERE lft >= :srcPosition AND rgt < :srcPosition + :space;", array('distance' => $distance, 'srcPosition' => $srcPosition, 'space' => $space)); // remove old space $this->_db->query("UPDATE {$this->_name} SET rgt = rgt - :space WHERE rgt > :srcPosition;", array('space' => $space, 'srcPosition' => $srcPosition)); $this->_db->query("UPDATE {$this->_name} SET lft = lft - :space WHERE lft >= :srcPosition;", array('space' => $space, 'srcPosition' => $srcPosition)); // move it $this->_db->commit(); } catch (Exception $e) { $this->_db->rollBack(); Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); return false; } return true; } /** * @param $productId * * @return array */ public function fetchMainCategoryForProduct($productId) { $sql = "SELECT `pc`.`project_category_id`, `pc`.`title` FROM `project_category` AS `pc` JOIN `project` AS `p` ON `p`.`project_category_id` = `pc`.`project_category_id` WHERE `p`.`project_id` = :projectId ;"; return $this->_db->fetchAll($sql, array('projectId' => $productId)); } /** * @param $productId * * @return array * @deprecated */ public function fetchAllCategoriesForProduct($productId) { $sql = "SELECT p.project_id, pc.project_category_id AS category_id, pc.title AS category, ps.project_category_id AS sub_category_id, ps.title AS sub_category FROM project AS p JOIN project_category AS pc ON p.project_category_id = pc.project_category_id LEFT JOIN (SELECT prc.project_category_id, psc.project_id, prc.title FROM project_subcategory AS psc JOIN project_category AS prc ON psc.project_sub_category_id) AS ps ON p.project_id = ps.project_id WHERE p.project_id = :projectId "; return $this->_db->fetchAll($sql, array('projectId' => $productId)); } /** * @param int $cat_id * * @return int|string * @throws Zend_Db_Table_Exception */ public function countSubCategories($cat_id) { $cat = $this->findCategory($cat_id); $countSubCat = (int)$cat->rgt - (int)$cat->lft - 1; if ($countSubCat < 0) { return 0; } else { return $countSubCat; } } /** * @param int $nodeId * * @return Zend_Db_Table_Row_Abstract * @throws Zend_Db_Table_Exception */ public function findCategory($nodeId) { if (is_null($nodeId) OR $nodeId == '') { return $this->createRow(); } $result = $this->find($nodeId); if (count($result) > 0) { return $result->current(); } else { return $this->createRow(); } } /** * @param $valueCatId * * @return array * @throws Zend_Cache_Exception * @throws Zend_Db_Statement_Exception */ public function fetchCategoriesForForm($valueCatId) { $level = 0; - $ancestors = array("catLevel-{$level}" => $this->fetchMainCatForSelect(Default_Model_DbTable_ProjectCategory::ORDERED_TITLE)); + $mainCatArray = $this->fetchMainCatForSelect(Default_Model_DbTable_ProjectCategory::ORDERED_TITLE); + $ancestors = array("catLevel-{$level}" => $mainCatArray); $level++; if (false == empty($valueCatId)) { + + foreach (array_keys($mainCatArray) as $element) { + if($element == $valueCatId) { + return $ancestors; + } + } + $categoryAncestors = $this->fetchAncestorsAsId($valueCatId); if ($categoryAncestors) { $categoryPath = explode(',', $categoryAncestors['ancestors']); foreach ($categoryPath as $element) { + $catResult = $this->fetchImmediateChildren($element, Default_Model_DbTable_ProjectCategory::ORDERED_TITLE); $ancestors["catLevel-{$level}"] = $this->prepareDataForFormSelect($catResult); $level++; } } } return $ancestors; } /** * @param string $orderBy * * @return array * @throws Zend_Cache_Exception * @throws Zend_Db_Statement_Exception */ public function fetchMainCatForSelect($orderBy = self::ORDERED_HIERARCHIC) { //$root = $this->fetchRoot(); //$resultRows = $this->fetchImmediateChildren($root['project_category_id'], $orderBy); $storeCatIds = Zend_Registry::isRegistered('store_category_list') ? Zend_Registry::get('store_category_list') : null; if(null == $storeCatIds) { $root = $this->fetchRoot(); $resultRows = $this->fetchImmediateChildren($root['project_category_id'], $orderBy); } else { $resultRows = $this->fetchImmediateChildren($storeCatIds, $orderBy, false); } $resultForSelect = $this->prepareDataForFormSelect($resultRows); return $resultForSelect; } /** * @param int|array $nodeId * @param string $orderBy * * @return array * @throws Zend_Cache_Exception * @throws Zend_Db_Statement_Exception */ public function fetchImmediateChildren($nodeId, $orderBy = 'lft', $search_fo_parent = true) { $str = is_array($nodeId) ? implode(',', $nodeId) : $nodeId; /** @var Zend_Cache_Core $cache */ $cache = $this->cache; $cacheName = __FUNCTION__ . '_' . md5($str . $orderBy . $search_fo_parent); if (false === ($children = $cache->load($cacheName))) { $inQuery = '?'; if (is_array($nodeId)) { $inQuery = implode(',', array_fill(0, count($nodeId), '?')); } $sql = ' SELECT node.*, (SELECT parent.project_category_id FROM project_category AS parent WHERE parent.lft < node.lft AND parent.rgt > node.rgt ORDER BY parent.rgt-node.rgt LIMIT 1) AS parent FROM project_category AS node WHERE node.is_active = 1 HAVING ' . ($search_fo_parent?'parent':'node.project_category_id') . ' IN (' . $inQuery . ') ORDER BY node.' . $orderBy . ' '; $children = $this->_db->query($sql, $nodeId)->fetchAll(); if (count($children) == 0) { $children = array(); } $cache->save($children, $cacheName, array(), 3600); } return $children; } /** * @param $resultRows * * @return array */ protected function prepareDataForFormSelect($resultRows) { $resultForSelect = array(); //$resultForSelect[''] = ''; foreach ($resultRows as $row) { $resultForSelect[$row['project_category_id']] = $row['title']; } return $resultForSelect; } /** * @param $catId * * @return array|mixed */ public function fetchAncestorsAsId($catId) { $sql = ' SELECT node.title, GROUP_CONCAT(parent.project_category_id ORDER BY parent.lft) AS ancestors FROM project_category AS node LEFT JOIN project_category AS parent ON parent.lft < node.lft AND parent.rgt > node.rgt AND parent.lft > 0 WHERE node.project_category_id = :categoryId GROUP BY node.project_category_id HAVING ancestors IS NOT NULL '; $result = $this->_db->fetchRow($sql, array('categoryId' => $catId)); if ($result AND count($result) > 0) { return $result; } else { return array(); } } /** * @param $resultRows * * @return array */ protected function prepareDataForFormSelectWithTitleKey($resultRows) { $resultForSelect = array(); //$resultForSelect[''] = ''; foreach ($resultRows as $row) { $resultForSelect[$row['title']] = $row['project_category_id']; } return $resultForSelect; } /** * @deprecated */ protected function initLocalCache() { $frontendOptions = array( 'lifetime' => 3600, 'automatic_serialization' => true ); $backendOptions = array( 'cache_dir' => APPLICATION_CACHE, 'file_locking' => true, 'read_control' => true, 'read_control_type' => 'adler32', // default 'crc32' 'hashed_directory_level' => 0, 'hashed_directory_perm' => 0700, 'file_name_prefix' => 'app', 'cache_file_perm' => 700 ); $this->cache = Zend_Cache::factory( 'Core', 'File', $frontendOptions, $backendOptions ); } } \ No newline at end of file diff --git a/application/modules/default/views/helpers/BuildMemberUrl.php b/application/modules/default/views/helpers/BuildBaseUrl.php similarity index 72% copy from application/modules/default/views/helpers/BuildMemberUrl.php copy to application/modules/default/views/helpers/BuildBaseUrl.php index 8a5feb6d4..9b91ff8f9 100644 --- a/application/modules/default/views/helpers/BuildMemberUrl.php +++ b/application/modules/default/views/helpers/BuildBaseUrl.php @@ -1,125 +1,142 @@ . **/ -class Default_View_Helper_BuildMemberUrl extends Zend_View_Helper_Abstract +class Default_View_Helper_BuildBaseUrl extends Zend_View_Helper_Abstract { /** * @param int|string $member_ident * @param string $action * @param array $params * * @return string * @throws Zend_Exception */ - public function buildMemberUrl($member_ident, $action = '', $params = null) + public function buildBaserUrl($action = '', $params = null) { /** @var Zend_Controller_Request_Http $request */ $request = Zend_Controller_Front::getInstance()->getRequest(); $http_scheme = $request->getScheme(); + + $baseurl = ''; + + $http_host = $request->getHttpHost(); + $http_scheme = isset($scheme) ? $scheme : $request->getScheme(); + $host = $http_scheme . '://' . $http_host; + + $storeId = null; + if (false === isset($params['store_id'])) { + if ($request->getParam('domain_store_id')) { + $storeId = 's/' . $request->getParam('domain_store_id'); + } + } else { + $storeId = "s/{$params['store_id']}"; + unset($params['store_id']); + } - $baseurl = Zend_Registry::get('config')->settings->client->default->baseurl; + //20190214 ronald: removed to stay in context, if set in store config + $storeConfig = Zend_Registry::isRegistered('store_config') ? Zend_Registry::get('store_config') : null; + + if(null != $storeConfig && $storeConfig->stay_in_context == false) { + $baseurl = Zend_Registry::get('config')->settings->client->default->baseurl; + } else { + + $baseurl = "{$host}/{$storeId}"; + } + $url_param = ''; if (is_array($params)) { array_walk($params, create_function('&$i,$k', '$i="$k/$i/";')); $url_param = implode('/', $params); } if ($action != '') { - $action = $action . '/'; + $action = $action; } - $member_ident = strtolower($member_ident); - $member_ident = urlencode($member_ident); - - $memberLink = "u"; - if(is_int($member_ident)) { - $memberLink = "member"; - } - - return "{$baseurl}/{$memberLink}/{$member_ident}/{$action}{$url_param}"; + return "{$baseurl}/{$action}{$url_param}"; } /** * @param int $member_id * @param string $action * @param array $params * @param bool $withHost * @param string $scheme * * @return string */ /* public function buildMemberUrl($member_id, $action = '', $params = null, $withHost = false, $scheme = null) { $request = Zend_Controller_Front::getInstance()->getRequest(); $host = ''; if ($withHost) { $http_scheme = isset($scheme) ? $scheme : $request->getScheme(); $host = $http_scheme . '://' . $request->getHttpHost(); } $storeId = null; if (false === isset($params['store_id'])) { if ($request->getParam('domain_store_id')) { $storeId = 's/' . $request->getParam('domain_store_id') . '/'; } } else { $storeId = "s/{$params['store_id']}/"; unset($params['store_id']); } $url_param = ''; if (is_array($params)) { array_walk($params, create_function('&$i,$k', '$i="$k/$i/";')); $url_param = implode('/', $params); } if ($action != '') { $action = $action . '/'; } return "{$host}/{$storeId}member/{$member_id}/{$action}{$url_param}"; } */ public function buildExternalUrl($member_id, $action = null, $params = null) { $url_param = ''; if (is_array($params)) { array_walk($params, create_function('&$i,$k', '$i="$k/$i/";')); $url_param = implode('/', $params); } if (isset($action)) { $action .= '/'; } $member_host = Zend_Registry::get('config')->settings->member->page->server; return "//{$member_host}/me/{$member_id}/{$action}{$url_param}"; } } \ No newline at end of file diff --git a/application/modules/default/views/helpers/BuildMemberUrl.php b/application/modules/default/views/helpers/BuildMemberUrl.php index 8a5feb6d4..a989b6ba2 100644 --- a/application/modules/default/views/helpers/BuildMemberUrl.php +++ b/application/modules/default/views/helpers/BuildMemberUrl.php @@ -1,125 +1,150 @@ . **/ class Default_View_Helper_BuildMemberUrl extends Zend_View_Helper_Abstract { /** * @param int|string $member_ident * @param string $action * @param array $params * * @return string * @throws Zend_Exception */ public function buildMemberUrl($member_ident, $action = '', $params = null) { /** @var Zend_Controller_Request_Http $request */ $request = Zend_Controller_Front::getInstance()->getRequest(); $http_scheme = $request->getScheme(); + + $baseurl = ''; + + $http_host = $request->getHttpHost(); + $http_scheme = isset($scheme) ? $scheme : $request->getScheme(); + $host = $http_scheme . '://' . $http_host; + + $storeId = null; + if (false === isset($params['store_id'])) { + if ($request->getParam('domain_store_id')) { + $storeId = 's/' . $request->getParam('domain_store_id'); + } + } else { + $storeId = "s/{$params['store_id']}"; + unset($params['store_id']); + } - $baseurl = Zend_Registry::get('config')->settings->client->default->baseurl; + //20190214 ronald: removed to stay in context, if set in store config + $storeConfig = Zend_Registry::isRegistered('store_config') ? Zend_Registry::get('store_config') : null; + + if(null != $storeConfig && $storeConfig->stay_in_context == false) { + $baseurl = Zend_Registry::get('config')->settings->client->default->baseurl; + } else { + + $baseurl = "{$host}/{$storeId}"; + } + $url_param = ''; if (is_array($params)) { array_walk($params, create_function('&$i,$k', '$i="$k/$i/";')); $url_param = implode('/', $params); } if ($action != '') { $action = $action . '/'; } $member_ident = strtolower($member_ident); $member_ident = urlencode($member_ident); $memberLink = "u"; if(is_int($member_ident)) { $memberLink = "member"; } return "{$baseurl}/{$memberLink}/{$member_ident}/{$action}{$url_param}"; } /** * @param int $member_id * @param string $action * @param array $params * @param bool $withHost * @param string $scheme * * @return string */ /* public function buildMemberUrl($member_id, $action = '', $params = null, $withHost = false, $scheme = null) { $request = Zend_Controller_Front::getInstance()->getRequest(); $host = ''; if ($withHost) { $http_scheme = isset($scheme) ? $scheme : $request->getScheme(); $host = $http_scheme . '://' . $request->getHttpHost(); } $storeId = null; if (false === isset($params['store_id'])) { if ($request->getParam('domain_store_id')) { $storeId = 's/' . $request->getParam('domain_store_id') . '/'; } } else { $storeId = "s/{$params['store_id']}/"; unset($params['store_id']); } $url_param = ''; if (is_array($params)) { array_walk($params, create_function('&$i,$k', '$i="$k/$i/";')); $url_param = implode('/', $params); } if ($action != '') { $action = $action . '/'; } return "{$host}/{$storeId}member/{$member_id}/{$action}{$url_param}"; } */ public function buildExternalUrl($member_id, $action = null, $params = null) { $url_param = ''; if (is_array($params)) { array_walk($params, create_function('&$i,$k', '$i="$k/$i/";')); $url_param = implode('/', $params); } if (isset($action)) { $action .= '/'; } $member_host = Zend_Registry::get('config')->settings->member->page->server; return "//{$member_host}/me/{$member_id}/{$action}{$url_param}"; } } \ No newline at end of file diff --git a/application/modules/default/views/scripts/partials/header/template.phtml b/application/modules/default/views/scripts/partials/header/template.phtml index b2af66ca8..032ba4ac4 100644 --- a/application/modules/default/views/scripts/partials/header/template.phtml +++ b/application/modules/default/views/scripts/partials/header/template.phtml @@ -1,428 +1,439 @@ . **/ $helperFetchCategory = new Default_View_Helper_CatTitle(); $helperFetchCatParent = new Default_View_Helper_CatParent(); $getAuthUser = new Default_View_Helper_GetAuthUser(); $helperBuildMemberUrl = new Default_View_Helper_BuildMemberUrl(); +$helperBuildBaseUrl = new Default_View_Helper_BuildBaseUrl(); $helperImage = new Default_View_Helper_Image(); $auth = Zend_Auth::getInstance(); $member = $getAuthUser->getAuthUser(); $phash = null; $ltat = null; if ($auth->hasIdentity()) { $sess = new Zend_Session_Namespace('ocs_meta'); $phash = $sess->phash; $ltat = $sess->openid; } $jsonmember = null; if($member && !empty($member->username)){ $jsonmember=array( 'member_id' => $member->member_id, 'username' => $member->username, 'avatar' => $member->avatar, 'profile_image_url' => $member->profile_image_url ); } $serverUrl = $this->serverUrl(); -$baseurl = Zend_Registry::get('config')->settings->client->default->baseurl; +//$baseurl = Zend_Registry::get('config')->settings->client->default->baseurl; +$baseurl = $helperBuildBaseUrl->buildBaserUrl(); $searchbaseurl = $this->buildSearchBaseUrl(); $sname = Zend_Registry::get('store_host'); $store_config = Zend_Registry::get('store_config'); $store_order = $store_config->order; $store_name = $store_config->name; $is_show_title = $store_config->is_show_title; $last_char_store_order = substr($store_order, -1); $url_forum = Zend_Registry::get('config')->settings->client->default->url_forum; $url_gitlab = Zend_Registry::get('config')->settings->client->default->url_gitlab; $url_blog = Zend_Registry::get('config')->settings->client->default->url_blog; $config_domain = $config = Zend_Registry::get('config')->settings->domain; $url_openid = $config_domain->openid->host; /** @var Zend_Controller_Request_Http $request */ $request = Zend_Controller_Front::getInstance()->getRequest(); $http_scheme = $request->getScheme(); $json_menu = $this->fetchMetaheaderMenuJson(); +$filter = new Local_Filter_Url_Encrypt(); +$thisurl = $helperBuildBaseUrl->buildBaserUrl(); +$url_logout = "/logout?redirect=".$filter->filter($thisurl); +$url_login = "/logint?redirect=".$filter->filter($thisurl); + + $cat_title = $helperFetchCategory->catTitle($this->cat_id); $category_id = $this->cat_id; $category_id_parent = $helperFetchCatParent->getCatParentId(array('project_category_id' => $category_id)); $cat_title_length = strlen($cat_title); //check logo-width: $logoWidth = (int)$this->template['header-logo']['width']; $cat_title_left = $logoWidth+60; $tabs_left = (int)$this->template['header-nav-tabs']['absolute-left']; $tabs_left += $cat_title_length*10; //$idCat = Zend_Registry::isRegistered('store_category_list') ? Zend_Registry::get('store_category_list') : null; //$helperUserRole = new Backend_View_Helper_UserRole(); //$userRoleName = $helperUserRole->userRole(); //$forum_url_postfix = Zend_Auth::getInstance()->hasIdentity() ? '/session/sso' : ''; echo $this->render('partials/header/metaheader.phtml'); ?>
hasIdentity() && empty($member->username)) { $helperEncryptUrl = new Default_View_Helper_EncryptUrl(); $redirectString = '/redirect/' . $helperEncryptUrl->EncryptUrl(Zend_Controller_Front::getInstance()->getRequest()->getScheme() . '://' . Zend_Controller_Front::getInstance()->getRequest()->getHttpHost().$_SERVER["REQUEST_URI"]); ?>
cat_id) ? $this->cat_id : 'all' ?>/order/latest"> *//*?>
*/?>
inlineScript()->appendScript( '$(document).ready(function(){ MenuHover.setup(); Popuppanel.setup(); LoginContainer.update(); PlingsRedirect.setup(); });' ); diff --git a/application/modules/default/views/scripts/partials/header/template_react.phtml b/application/modules/default/views/scripts/partials/header/template_react.phtml index aa23b7307..c5633a99d 100755 --- a/application/modules/default/views/scripts/partials/header/template_react.phtml +++ b/application/modules/default/views/scripts/partials/header/template_react.phtml @@ -1,236 +1,243 @@ . **/ -$baseurl = Zend_Registry::get('config')->settings->client->default->baseurl; +$helperBuildBaseUrl = new Default_View_Helper_BuildBaseUrl(); +//$baseurl = Zend_Registry::get('config')->settings->client->default->baseurl; +$baseurl = $helperBuildBaseUrl->buildBaserUrl(); $sname = Zend_Registry::get('store_host'); $store_config = Zend_Registry::get('store_config'); $getAuthUser = new Default_View_Helper_GetAuthUser(); $helperBuildMemberUrl = new Default_View_Helper_BuildMemberUrl(); + $helperImage = new Default_View_Helper_Image(); $auth = Zend_Auth::getInstance(); $member = $getAuthUser->getAuthUser(); $serverUrl = $this->serverUrl(); $store_order = $store_config->order; $store_name = $store_config->name; $is_show_title = $store_config->is_show_title; $last_char_store_order = substr($store_order, -1); $helperFetchCategory = new Default_View_Helper_CatTitle(); $cat_title = $helperFetchCategory->catTitle($this->cat_id); $cat_title_length = strlen($cat_title); //check logo-width: $logoWidth = (int)$this->template['header-logo']['width']; $cat_title_left = $logoWidth+60; $tabs_left = (int)$this->template['header-nav-tabs']['absolute-left']; $tabs_left += $cat_title_length*10; +$filter = new Local_Filter_Url_Encrypt(); +$thisurl = $helperBuildBaseUrl->buildBaserUrl(); +$url_logout = "/logout?redirect=".$filter->filter($thisurl); + ?> render('partials/header/metaheader_react.phtml'); ?>
hasIdentity() && empty($member->username)) { $helperEncryptUrl = new Default_View_Helper_EncryptUrl(); $redirectString = '/redirect/' . $helperEncryptUrl->EncryptUrl(Zend_Controller_Front::getInstance()->getRequest()->getScheme() . '://' . Zend_Controller_Front::getInstance()->getRequest()->getHttpHost().$_SERVER["REQUEST_URI"]); ?>
cat_id) ? $this->cat_id : 'all' ?>/order/latest"> */?>
inlineScript()->appendScript( ' $(document).ready(function(){ MenuHover.setup(); Popuppanel.setup(); LoginContainer.update(); PlingsRedirect.setup(); }); '); diff --git a/application/modules/default/views/scripts/product/add.phtml b/application/modules/default/views/scripts/product/add.phtml index e120916f8..00245f119 100644 --- a/application/modules/default/views/scripts/product/add.phtml +++ b/application/modules/default/views/scripts/product/add.phtml @@ -1,2138 +1,2150 @@ . **/ //$this->os = Zend_Registry::get('application_os'); $this->tab = 'add'; $helperImage = new Default_View_Helper_Image(); $helpMemberUrl = new Default_View_Helper_BuildMemberUrl(); $helpProductUrl = new Default_View_Helper_BuildProductUrl(); +$helpBaseUrl = new Default_View_Helper_BaseUrl(); $modelCategory = new Default_Model_DbTable_ProjectCategory(); $valueCatId = $this->form->project_category_id->getValue(); //$valueCatId = 55; +$storeCatIds = Zend_Registry::isRegistered('store_category_list') ? Zend_Registry::get('store_category_list') : null; $categories = $modelCategory->fetchCategoriesForForm($valueCatId); $categoryAncestors = $modelCategory->fetchAncestorsAsId($valueCatId); + if (count($categoryAncestors) > 0) { $categoryPath = explode(',',$categoryAncestors['ancestors']); } $categoryPath[] = $valueCatId; + $this->headLink()->appendStylesheet('/theme/flatui/css/chosen.css'); $this->inlineScript()->appendFile('/theme/flatui/js/lib/chosen.jquery.min.js'); $this->inlineScript()->appendScript(' $(document).ready(function(){ $("select.chosen").chosen({ width: "100%", max_selected_options: "5", disable_search: "false", disable_search_threshold: "5" }); }); '); ?>
profile-image
Hi member->username; ?>translate(', welcome to your personal start page!') ?>
render('user/partials/userHeader.phtml'); ?>
form->project_id ?>

Basics

(*) Mandatory fields.

form->title ?>
*
value="escape($this->form->title->getValue()) ?>" title="Please use only letters." maxlength="60" aria-required="true" aria-invalid="false" data-rule-minlength="4" data-rule-maxlength="60" data-msg-minlength="At least 4 chars" data-msg-maxlength="At most 60 chars"> form->title->getMessages()) { $errorHtml = ''; foreach ($this->form->title->getMessages() as $currentError) { $errorHtml .= ''; } ?>
form->project_category_id ?> form->project_subcategory_id ?> form->project_sub_subcategory_id ?> form->description ?> form->version ?> form->source_url ?>
form->is_original ?> Check this box, if this is your own original work and not based on something else
form->license_tag_id ?> project_id) { $tagmodel = new Default_Model_Tags(); $tagscat = $tagmodel->getTagsCategory($this->project_id, Default_Model_Tags::TAG_TYPE_PROJECT); if(strlen($tagscat)>0) { ?>
form->tagsuser ?> form->image_small ?> form->image_small_upload ?> form->image_big ?> form->image_big_upload ?> form->gallery ?> form->embed_code ?> form->link_1 ?> form->facebook_code ?> form->twitter_code ?> form->google_code ?>

Git

form->gitlab_project_id->getMultiOptions())) { ?>
form->is_gitlab_project ?> Check this box, if this a public project on git.opendesktop.org
product) || (!empty($this->product) && $this->product->is_gitlab_project == 0)) { $this->form->gitlab_project_id->setAttrib('disabled', 'disabled'); } ?> form->gitlab_project_id ?>
product) || (!empty($this->product) && $this->product->is_gitlab_project == 0)) { $this->form->show_gitlab_project_issues->setAttrib('disabled', 'disabled'); } ?> form->show_gitlab_project_issues ?> Check this box, if you want to show the issue list
product) || (!empty($this->product) && $this->product->is_gitlab_project == 0)) { $this->form->use_gitlab_project_readme->setAttrib('disabled', 'disabled'); } ?> form->use_gitlab_project_readme ?> Check this box, if you want to show the README.md as project description
You can create a project on git.opendesktop.org and link it with this project.

Files

project_id)) { ?>

Changelog

inlineScript()->appendScript( ' $(document).ready(function(){ ImagePreview.setup(); ProductForm.setup(); ProductGallery.setup(); Opendownloadfile.setup(); $(\'#demo\').multiselect({ includeSelectAllOption: true }); }); '); diff --git a/application/modules/default/views/scripts/product/partials/partialComment.phtml b/application/modules/default/views/scripts/product/partials/partialComment.phtml index 719671631..18231aa12 100644 --- a/application/modules/default/views/scripts/product/partials/partialComment.phtml +++ b/application/modules/default/views/scripts/product/partials/partialComment.phtml @@ -1,99 +1,100 @@ . **/ $helperHumanTiming = new Default_View_Helper_HumanTiming(); $helperBuildMemberUrl = new Default_View_Helper_BuildMemberUrl(); +$helperBuildBaseUrl = new Default_View_Helper_BuildBaseUrl(); $helperUserIsOwner = new Default_View_Helper_UserIsOwner(); $helperImage = new Default_View_Helper_Image(); $comment = $this->comment; $marginLeft = $this->marginLeft; $age = $helperHumanTiming->humanTiming($comment['comment_created_at']); ?>
by on: ago

hasIdentity()) { $identity = Zend_Auth::getInstance()->getStorage()->read(); ?> Reply to this
diff --git a/application/modules/default/views/scripts/product/partials/productComments.phtml b/application/modules/default/views/scripts/product/partials/productComments.phtml index 02d1c614c..7e0042e40 100644 --- a/application/modules/default/views/scripts/product/partials/productComments.phtml +++ b/application/modules/default/views/scripts/product/partials/productComments.phtml @@ -1,105 +1,106 @@ . **/ $helperHumanTiming = new Default_View_Helper_HumanTiming(); $helperBuildMemberUrl = new Default_View_Helper_BuildMemberUrl(); +$helperBuildBaseUrl = new Default_View_Helper_BuildBaseUrl(); $helperUserIsOwner = new Default_View_Helper_UserIsOwner(); $helperImage = new Default_View_Helper_Image(); ?>

Comments

comments) == 0) { ?>
Be the first to comment
paginationControl($this->comments, 'Sliding', '/partials/paginationControlBootstrap.phtml', array('params' => array(), 'dom_target' => 'div#product-discussion')); ?>
comments as $comment): //printComment($comment, $this, $this->product); echo $this->render('/product/partials/partialComment.phtml', array('comment' => $comment['comment'], 'marginLeft' => 30 * $comment['level'], 'product' => $this->product)); endforeach; ?>
paginationControl($this->comments, 'Sliding', '/partials/paginationControlBootstrap.phtml', array('params' => array(), 'dom_target' => 'div#product-discussion')); ?>
hasIdentity()) { $identity = Zend_Auth::getInstance()->getStorage()->read(); ?> add comment
\ No newline at end of file diff --git a/application/modules/default/views/scripts/product/partials/productCommentsUX1.phtml b/application/modules/default/views/scripts/product/partials/productCommentsUX1.phtml index c84051949..92e4b8a98 100644 --- a/application/modules/default/views/scripts/product/partials/productCommentsUX1.phtml +++ b/application/modules/default/views/scripts/product/partials/productCommentsUX1.phtml @@ -1,225 +1,226 @@ . **/ $helperEncryptUrl = new Default_View_Helper_EncryptUrl(); $requestUri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri(); $helpProductUrl = new Default_View_Helper_BuildProductUrl(); $productUrl = $helpProductUrl->buildProductUrl($this->product->project_id); $loginUrl = '/login?redirect=' . $helperEncryptUrl->encryptUrl($productUrl.'#comments_block', true); $helperHumanTiming = new Default_View_Helper_HumanTiming(); $helperBuildMemberUrl = new Default_View_Helper_BuildMemberUrl(); +$helperBuildBaseUrl = new Default_View_Helper_BuildBaseUrl(); $helperImage = new Default_View_Helper_Image(); $identity = Zend_Auth::getInstance()->getStorage()->read(); $pageCount = $this->comments->getTotalItemCount()/$this->comments->getItemCountPerPage(); //$captcha = new Zend_Captcha_Image(array( // 'name' => 'foo', // 'wordLen' => 6, // 'timeout' => 300, //)); //$captcha->setFont(APPLICATION_PATH . '/../httpdocs/theme/flatui/fonts/OpenSans-Regular.ttf'); //$captcha->generate(); ?>
comments->getCurrentItemCount()) { ?>
Be the first to comment
comments as $elementComment): ?> humanTiming($comment['comment_created_at']); // $captcha = new Zend_Form_Element_Captcha('realHuman',array( // 'captcha' => array( // 'captcha' => 'image', // 'font' => APPLICATION_PATH . '/../httpdocs/theme/flatui/fonts/OpenSans-Regular.ttf', // 'wordLen' => 6, // 'timeout' => 300, // 'width' => 250 // )) // ); // $captcha->setAttrib('placeholder', 'Please verify you\'re a human'); // $captcha->setAttrib('class', 'full-width'); ?>

product->member_id == $comment['member_id']){ ?> C S
MOD

0) { ?> ago

'; }else { echo ''; } } ?>

hasIdentity()) { ?> Reply   Report Report

hasIdentity()) { ?>
-
+ render($this); ?>
1) echo $this->paginationControl($this->comments, 'Sliding', '/partials/paginationControlComment.phtml', array('params' => array('project_id'=>$this->product->project_id), 'dom_target' => 'div#product-discussion')); ?>
inlineScript()->appendScript( ' $(document).ready(function(){ AjaxForm.setup("form.product-add-comment", "div#product-discussion"); ProductDetailCommentTooltip.setup(); }); '); \ No newline at end of file diff --git a/application/modules/default/views/scripts/user/partials/aboutme-likes.phtml b/application/modules/default/views/scripts/user/partials/aboutme-likes.phtml index 47068f916..4ff5639fc 100755 --- a/application/modules/default/views/scripts/user/partials/aboutme-likes.phtml +++ b/application/modules/default/views/scripts/user/partials/aboutme-likes.phtml @@ -1,63 +1,63 @@ . **/ foreach ($this->likes as $file): $file=(object)$file; ?>
- title?> + title?>

cat_title?>

by project_username?>
widgetRating = new stdClass(); $this->widgetRating->project_id =$file->project_id; $this->widgetRating->laplace_score = $file->laplace_score; $this->widgetRating->count_likes =$file->count_likes; $this->widgetRating->count_dislikes =$file->count_dislikes; echo $this->render('partials/widgetRating.phtml'); ?>
printDate($file->created_at)?>
\ No newline at end of file diff --git a/application/modules/default/views/scripts/user/partials/aboutme-plings.phtml b/application/modules/default/views/scripts/user/partials/aboutme-plings.phtml index 613587370..dd0715e71 100755 --- a/application/modules/default/views/scripts/user/partials/aboutme-plings.phtml +++ b/application/modules/default/views/scripts/user/partials/aboutme-plings.phtml @@ -1,63 +1,63 @@ . **/ foreach ($this->plings as $file): $file=(object)$file; ?>
- title?> + title?>

cat_title?>

by project_username?>
widgetRating = new stdClass(); $this->widgetRating->project_id =$file->project_id; $this->widgetRating->laplace_score = $file->laplace_score; $this->widgetRating->count_likes =$file->count_likes; $this->widgetRating->count_dislikes =$file->count_dislikes; echo $this->render('partials/widgetRating.phtml'); ?>
printDate($file->created_at)?>
\ No newline at end of file diff --git a/application/modules/default/views/scripts/user/partials/loopDownloadHistory.phtml b/application/modules/default/views/scripts/user/partials/loopDownloadHistory.phtml index d75c378a7..5ac4030b1 100644 --- a/application/modules/default/views/scripts/user/partials/loopDownloadHistory.phtml +++ b/application/modules/default/views/scripts/user/partials/loopDownloadHistory.phtml @@ -1,133 +1,133 @@ fetchRate($this->file->project_id, $this->member_id); $userrate ="data-userrate='-1'"; $comment="data-comment=''"; if($userRateData){ $userrate ="data-userrate='".$userRateData['user_like']."'"; $comment="data-comment='".$userRateData['comment_text']."'"; } $formproject="data-project='".$this->file->project_id."'"; $attrhistory = $userrate.' '.$comment.' '.$formproject; if($this->counter==0){ ?>
- file->title?> + file->title?>

file->catTitle?>

file->max_downloaded_timestamp?>
widgetRating = new stdClass(); $this->widgetRating->project_id =$this->file->project_id; $this->widgetRating->laplace_score = $this->file->laplace_score; $this->widgetRating->count_likes =$this->file->count_likes; $this->widgetRating->count_dislikes =$this->file->count_dislikes; echo $this->render('partials/widgetRating.phtml'); ?>
file->project_member_id<> $this->authMember->member_id) { $votedownactive = ""; $voteupactive = ""; if($userRateData && $userRateData['user_like']>0){ $voteupactive = "active"; }else{ if($userRateData) $votedownactive = "active"; } ?> printDate($userRateData['created_at']); } ?>
file->project_member_id<> $this->authMember->member_id){ echo $this->partial( '/product/follow.phtml', array( "authMember" => $this->authMember, "project_id" => $this->file->project_id ) ); } ?>
file->file_name?>
humanFilesize($this->file->file_size)?>
file->downloaded_timestamp?>
file->file_type?>
file->file_name?>
humanFilesize($this->file->file_size)?>
file->downloaded_timestamp?>
file->file_type?>
\ No newline at end of file diff --git a/application/modules/default/views/scripts/user/partials/loopLike.phtml b/application/modules/default/views/scripts/user/partials/loopLike.phtml index c5ff6da83..afadf30c1 100644 --- a/application/modules/default/views/scripts/user/partials/loopLike.phtml +++ b/application/modules/default/views/scripts/user/partials/loopLike.phtml @@ -1,38 +1,38 @@
- file->title?> + file->title?>

file->cat_title?>

by file->project_username?>
widgetRating = new stdClass(); $this->widgetRating->project_id =$this->file->project_id; $this->widgetRating->laplace_score = $this->file->laplace_score; $this->widgetRating->count_likes =$this->file->count_likes; $this->widgetRating->count_dislikes =$this->file->count_dislikes; echo $this->render('partials/widgetRating.phtml'); ?>
printDate($this->file->created_at)?>
diff --git a/application/modules/default/views/scripts/user/partials/loopMyComments.phtml b/application/modules/default/views/scripts/user/partials/loopMyComments.phtml index 614282620..aac258c87 100644 --- a/application/modules/default/views/scripts/user/partials/loopMyComments.phtml +++ b/application/modules/default/views/scripts/user/partials/loopMyComments.phtml @@ -1,140 +1,140 @@ . **/ $pageCount = $this->comments->count(); $helperBuildProductUrl = new Default_View_Helper_BuildProductUrl(); $helperFetchSubcategoriesForProduct = new Default_View_Helper_FetchCategoriesForProductAsString(); $helperPrintDate = new Default_View_Helper_PrintDate(); ?>
1) { echo $this->paginationControl($this->comments, 'Sliding', '/partials/paginationControlBootstrap.phtml', array('params' => array(), 'dom_target' => 'div#my-comments-tabs-content')); } ?>
result = array(); foreach ($this->comments as $element) { $this->result[$element['project_id']][] = $element; } foreach($this->result as $this->projects){ $i = 0; foreach($this->projects as $file){ $file=(object)$file; if($i==0){ ?>
- title?> + title?>

cat_title?> count_comments; echo ($count_comments>0 ? $count_comments.' comment':'').($count_comments>1?'s':''); ?>

widgetRating = new stdClass(); $this->widgetRating->project_id =$file->project_id; $this->widgetRating->laplace_score = $file->laplace_score; $this->widgetRating->count_likes =$file->count_likes; $this->widgetRating->count_dislikes =$file->count_dislikes; echo $this->render('partials/widgetRating.phtml'); ?>
printDate($file->changed_at==null?$file->created_at:$file->changed_at)?>
comment_text); ?> comment_text,true) ?> - printDate($file->comment_created_at); ?>
comment_text); ?> comment_text,true) ?> - printDate($file->comment_created_at); ?>
'; } ?>
diff --git a/application/modules/default/views/scripts/user/partials/loopPlingsForMonth.phtml b/application/modules/default/views/scripts/user/partials/loopPlingsForMonth.phtml index c4a09e95e..7629e1287 100644 --- a/application/modules/default/views/scripts/user/partials/loopPlingsForMonth.phtml +++ b/application/modules/default/views/scripts/user/partials/loopPlingsForMonth.phtml @@ -1,342 +1,342 @@ . **/ ?> "; if($showErrMsg) { echo '
'; } else { print($currency->toCurrency($product['num_downloads'] * $product['dl_pling_factor'] / 100)); } ?>
0) { $show_payout_new_sum = $show_payout_new_sum ; } else { $show_payout_new_sum = $payout_sum_new; } ?> toCurrency($sum_total_month_score); $sum_total_month_potential_payout += ($product['num_downloads'] * $product['dl_pling_factor'] / 100); $sum_total_potential_payout = $currency->toCurrency($sum_total_month_potential_payout); if(!$showErrMsg) { $sum_total_month += $payout_sum; $sum_total_payout = $currency->toCurrency($sum_total_month); $sum_total_month_new += $show_payout_new_sum; $sum_total_payout_new = $currency->toCurrency($sum_total_month_new); } $sum_total_text = 'Possible payout for this month (*):'; $payout_success = false; if ($product['status'] == Default_Model_DbTable_MemberPayout::$PAYOUT_STATUS_COMPLETED) { $payout_success = true; $sum_total_payout_success = $currency->toCurrency($product['amount']); $sum_total_text_success = 'Actually successfully paid amount: '; } $has_paypal = $product['paypal_mail'] ? true : false; } $sum_total_month_view = number_format($sum_total_month); ?>
view_member; if(!isset($member['paypal_mail']) || $member['paypal_mail'] == '') { $has_paypal = false; $paypalWarning = 'You have no PayPal account configured. Please go to your settings page here.'; } else { $has_paypal = true; } } else { $paypalWarning = 'We found no valid Paypal account for this month. That\'s why we could not pay you any money. In order to receive money for the current month, please make sure that a paypal account is registered. Go to your settings page here.'; } if (false == $has_paypal) { echo ''; } if (($sum_total_month/100) < 1) { echo ''; } ?> '; echo '
No Data
'; echo '
'; echo '
Possible payout for this month (*):
$0.00
'; echo '
'; echo ''; } ?>

(**) The Payout is planned to become active on May 2019.

*/ ?> inlineScript()->appendScript( ' $(document).ready(function(){ $(\'[data-toggle="popover"]\').popover(); }); '); \ No newline at end of file diff --git a/application/modules/default/views/scripts/user/partials/loopRated.phtml b/application/modules/default/views/scripts/user/partials/loopRated.phtml index 600a2eaea..0a9606523 100755 --- a/application/modules/default/views/scripts/user/partials/loopRated.phtml +++ b/application/modules/default/views/scripts/user/partials/loopRated.phtml @@ -1,71 +1,71 @@ . **/ foreach ($this->rated as $file): $file=(object)$file; ?>
- title?> + title?>

cat_title?>

by project_username?>
widgetRating = new stdClass(); $this->widgetRating->project_id =$file->project_id; $this->widgetRating->laplace_score = $file->laplace_score; $this->widgetRating->count_likes =$file->count_likes; $this->widgetRating->count_dislikes =$file->count_dislikes; echo $this->render('partials/widgetRating.phtml'); ?>
printDate($file->rating_created_at)?> user_like==1) { ?> comment_text?>
\ No newline at end of file diff --git a/application/modules/default/views/scripts/user/partials/userHeader.phtml b/application/modules/default/views/scripts/user/partials/userHeader.phtml index 0309bb09f..d026d09ea 100644 --- a/application/modules/default/views/scripts/user/partials/userHeader.phtml +++ b/application/modules/default/views/scripts/user/partials/userHeader.phtml @@ -1,110 +1,111 @@ . **/ $helperMember = new Default_View_Helper_BuildMemberUrl(); +$helperBase = new Default_View_Helper_BuildBaseUrl(); ?>
\ No newline at end of file diff --git a/httpdocs/theme/react/app-header/app.js b/httpdocs/theme/react/app-header/app.js index 596021e4a..0a8a82d48 100644 --- a/httpdocs/theme/react/app-header/app.js +++ b/httpdocs/theme/react/app-header/app.js @@ -1,403 +1,404 @@ class SiteHeader extends React.Component { constructor(props){ super(props); this.state = { baseUrl:window.json_baseurl, searchbaseurl:window.json_searchbaseurl, cat_title:window.json_cat_title, hasIdentity:window.json_hasIdentity, is_show_title:window.json_is_show_title, redirectString:window.json_redirectString, serverUrl:window.json_serverUrl, serverUri:window.json_serverUri, store:{ sName:window.json_sname, name:window.json_store_name, order:window.json_store_order, last_char_store_order:window.last_char_store_order, }, user:window.json_member, logo:window.json_logoWidth, cat_title_left:window.json_cat_title_left, tabs_left:window.tabs_left, template:window.json_template, - status:"" + status:"", + url_logout:window.json_logouturl }; this.updateDimensions = this.updateDimensions.bind(this); } componentWillMount() { this.updateDimensions(); } componentDidMount() { window.addEventListener("resize", this.updateDimensions); window.addEventListener("orientationchange",this.updateDimensions); } updateDimensions(){ const width = window.innerWidth; let device; if (width >= 910){ device = "large"; } else if (width < 910 && width >= 610){ device = "mid"; } else if (width < 610){ device = "tablet"; } this.setState({device:device}); } render(){ let userMenuDisplay, loginMenuDisplay, siteHeaderTopRightCssClass; if (this.state.user){ userMenuDisplay = ( ); siteHeaderTopRightCssClass = "w-user"; } else { loginMenuDisplay = ( ); } let logoLink = this.state.serverUrl; if (this.state.serverUri.indexOf('/s/') > -1){ logoLink += "/s/" + this.state.store.name; } let siteHeaderStoreNameDisplay; if (this.state.is_show_title === "1"){ siteHeaderStoreNameDisplay = ( ); } let HeaderDisplay; if (this.state.device !== "tablet"){ HeaderDisplay = ( ); } else { HeaderDisplay = ( ) } let templateHeaderStyle; if (this.state.template){ templateHeaderStyle = { "backgroundImage":this.state.template.header['background-image'], "backgroundColor":this.state.template.header['background-color'], "height":this.state.template.header['height'] } } return ( ) } } class SiteHeaderSearchForm extends React.Component { constructor(props){ super(props); this.state = { searchText:'' }; this.onSearchTextChange = this.onSearchTextChange.bind(this); this.onSearchFormSubmit = this.onSearchFormSubmit.bind(this); } onSearchTextChange(e){ this.setState({searchText:e.target.value}); } onSearchFormSubmit(e){ e.preventDefault(); window.location.href = this.props.searchbaseurl + this.state.searchText; } render(){ return (
) } } class SiteHeaderLoginMenu extends React.Component { constructor(props){ super(props); this.state = {}; } render(){ let registerButtonCssClass, loginButtonCssClass; if (window.location.href.indexOf('/register') > -1){ registerButtonCssClass = "active"; } if (window.location.href.indexOf('/login') > -1){ loginButtonCssClass = "active"; } const menuItemCssClass = { "borderColor":this.props.template['header-nav-tabs']['border-color'], "backgroundColor":this.props.template['header-nav-tabs']['background-color'] } return ( ) } } class SiteHeaderUserMenu extends React.Component { constructor(props){ super(props); this.state = {}; this.handleClick = this.handleClick.bind(this); } componentWillMount() { document.addEventListener('mousedown',this.handleClick, false); } componentWillUnmount() { document.removeEventListener('mousedown',this.handleClick, false); } handleClick(e){ let dropdownClass = ""; if (this.node.contains(e.target)){ if (this.state.dropdownClass === "open"){ if (e.target.className === "profile-menu-toggle" || e.target.className === "profile-menu-image" ||  e.target.className === "profile-menu-username"){ dropdownClass = ""; } else { dropdownClass = "open"; } } else { dropdownClass = "open"; } } this.setState({dropdownClass:dropdownClass}); } render(){ return ( ) } } class MobileSiteHeader extends React.Component { constructor(props){ super(props); this.state = { status:"switch" }; this.showMobileUserMenu = this.showMobileUserMenu.bind(this); this.showMobileSearchForm = this.showMobileSearchForm.bind(this); this.showMobileSwitchMenu = this.showMobileSwitchMenu.bind(this); } showMobileUserMenu(){ this.setState({status:"user"}); } showMobileSearchForm(){ this.setState({status:"search"}); } showMobileSwitchMenu(){ this.setState({status:"switch"}); } render(){ const menuItemCssClass = { "borderColor":this.props.template['header-nav-tabs']['border-color'], "backgroundColor":this.props.template['header-nav-tabs']['background-color'] } const closeMenuElementDisplay = ( ); let mobileMenuDisplay; if (this.state.status === "switch"){ mobileMenuDisplay = ( ); } else if (this.state.status === "user"){ mobileMenuDisplay = (
{closeMenuElementDisplay}
) } else if (this.state.status === "search"){ mobileMenuDisplay = (
{closeMenuElementDisplay}
) } let logoElementCssClass = this.props.store.name; if (this.state.status !== "switch"){ logoElementCssClass += " mini-version"; } return(
{mobileMenuDisplay}
); } } class MobileUserContainer extends React.Component { constructor(props){ super(props); this.state = {}; } render(){ let userDisplay; if (this.props.user){ userDisplay = ( ); } else { userDisplay = ( ); } return (
{userDisplay}
) } } ReactDOM.render( , document.getElementById('site-header-container') ); diff --git a/httpdocs/theme/react/header.js b/httpdocs/theme/react/header.js index 09f0aad86..a04714181 100644 --- a/httpdocs/theme/react/header.js +++ b/httpdocs/theme/react/header.js @@ -1,514 +1,515 @@ window.appHelpers = function () { function getEnv(domain) { let env; let lastDotSplit = this.splitByLastDot(domain); if (lastDotSplit.indexOf('/') > -1) { lastDotSplit = lastDotSplit.split('/')[0]; } if (lastDotSplit === 'com' || lastDotSplit === 'org') { env = 'live'; } else { env = 'test'; } return env; } function splitByLastDot(text) { var index = text.lastIndexOf('.'); return text.slice(index + 1); } return { getEnv, splitByLastDot }; }(); class SiteHeader extends React.Component { constructor(props) { super(props); this.state = { baseUrl: window.json_baseurl, searchbaseurl: window.json_searchbaseurl, cat_title: window.json_cat_title, hasIdentity: window.json_hasIdentity, is_show_title: window.json_is_show_title, redirectString: window.json_redirectString, serverUrl: window.json_serverUrl, serverUri: window.json_serverUri, store: { sName: window.json_sname, name: window.json_store_name, order: window.json_store_order, last_char_store_order: window.last_char_store_order }, user: window.json_member, logo: window.json_logoWidth, cat_title_left: window.json_cat_title_left, tabs_left: window.tabs_left, template: window.json_template, - status: "" + status: "", + url_logout:window.json_logouturl }; this.updateDimensions = this.updateDimensions.bind(this); } componentWillMount() { this.updateDimensions(); } componentDidMount() { window.addEventListener("resize", this.updateDimensions); window.addEventListener("orientationchange", this.updateDimensions); } updateDimensions() { const width = window.innerWidth; let device; if (width >= 910) { device = "large"; } else if (width < 910 && width >= 610) { device = "mid"; } else if (width < 610) { device = "tablet"; } this.setState({ device: device }); } render() { let userMenuDisplay, loginMenuDisplay, siteHeaderTopRightCssClass; if (this.state.user) { userMenuDisplay = React.createElement(SiteHeaderUserMenu, { serverUrl: this.state.serverUrl, baseUrl: this.state.baseUrl, user: this.state.user }); siteHeaderTopRightCssClass = "w-user"; } else { loginMenuDisplay = React.createElement(SiteHeaderLoginMenu, { baseUrl: this.state.baseUrl, redirectString: this.state.redirectString, template: this.state.template }); } let logoLink = this.state.serverUrl; if (this.state.serverUri.indexOf('/s/') > -1) { logoLink += "/s/" + this.state.store.name; } let siteHeaderStoreNameDisplay; if (this.state.is_show_title === "1") { siteHeaderStoreNameDisplay = React.createElement( "div", { id: "site-header-store-name-container" }, React.createElement( "a", { href: logoLink }, this.state.store.name ) ); } let HeaderDisplay; if (this.state.device !== "tablet") { HeaderDisplay = React.createElement( "section", { id: "site-header-wrapper", style: { "paddingLeft": this.state.template['header-logo']['width'] } }, React.createElement( "div", { id: "siter-header-left" }, React.createElement( "div", { id: "site-header-logo-container", style: this.state.template['header-logo'] }, React.createElement( "a", { href: logoLink }, React.createElement("img", { src: this.state.template['header-logo']['image-src'] }) ) ), siteHeaderStoreNameDisplay ), React.createElement( "div", { id: "site-header-right" }, React.createElement( "div", { id: "site-header-right-top", className: siteHeaderTopRightCssClass }, React.createElement(SiteHeaderSearchForm, { baseUrl: this.state.baseUrl, searchbaseurl: this.state.searchbaseurl }), userMenuDisplay ), React.createElement( "div", { id: "site-header-right-bottom" }, loginMenuDisplay ) ) ); } else { HeaderDisplay = React.createElement(MobileSiteHeader, { logoLink: logoLink, template: this.state.template, user: this.state.user, baseUrl: this.state.baseUrl, serverUrl: this.state.serverUrl, store: this.state.store, redirectString: this.state.redirectString }); } let templateHeaderStyle; if (this.state.template) { templateHeaderStyle = { "backgroundImage": this.state.template.header['background-image'], "backgroundColor": this.state.template.header['background-color'], "height": this.state.template.header['height'] }; } return React.createElement( "section", { id: "site-header", style: templateHeaderStyle }, HeaderDisplay ); } } class SiteHeaderSearchForm extends React.Component { constructor(props) { super(props); this.state = { searchText: '' }; this.onSearchTextChange = this.onSearchTextChange.bind(this); this.onSearchFormSubmit = this.onSearchFormSubmit.bind(this); } onSearchTextChange(e) { this.setState({ searchText: e.target.value }); } onSearchFormSubmit(e) { e.preventDefault(); window.location.href = this.props.searchbaseurl + this.state.searchText; } render() { return React.createElement( "div", { id: "site-header-search-form" }, React.createElement( "form", { id: "search-form", onSubmit: this.onSearchFormSubmit }, React.createElement("input", { onChange: this.onSearchTextChange, value: this.state.searchText, type: "text", name: "projectSearchText" }), React.createElement("a", { onClick: this.onSearchFormSubmit }) ) ); } } class SiteHeaderLoginMenu extends React.Component { constructor(props) { super(props); this.state = {}; } render() { let registerButtonCssClass, loginButtonCssClass; if (window.location.href.indexOf('/register') > -1) { registerButtonCssClass = "active"; } if (window.location.href.indexOf('/login') > -1) { loginButtonCssClass = "active"; } const menuItemCssClass = { "borderColor": this.props.template['header-nav-tabs']['border-color'], "backgroundColor": this.props.template['header-nav-tabs']['background-color'] }; return React.createElement( "div", { id: "site-header-login-menu" }, React.createElement( "ul", null, React.createElement( "li", { style: menuItemCssClass, className: registerButtonCssClass }, React.createElement( "a", - { href: "/register" }, + { href: this.props.baseUrl + "register" }, "Register" ) ), React.createElement( "li", { style: menuItemCssClass, className: loginButtonCssClass }, React.createElement( "a", - { href: "/login" + this.props.redirectString }, + { href: this.props.baseUrl + "login" + this.props.redirectString }, "Login" ) ) ) ); } } class SiteHeaderUserMenu extends React.Component { constructor(props) { super(props); this.state = {}; this.handleClick = this.handleClick.bind(this); } componentWillMount() { document.addEventListener('mousedown', this.handleClick, false); } componentWillUnmount() { document.removeEventListener('mousedown', this.handleClick, false); } handleClick(e) { let dropdownClass = ""; if (this.node.contains(e.target)) { if (this.state.dropdownClass === "open") { if (e.target.className === "profile-menu-toggle" || e.target.className === "profile-menu-image" || e.target.className === "profile-menu-username") { dropdownClass = ""; } else { dropdownClass = "open"; } } else { dropdownClass = "open"; } } this.setState({ dropdownClass: dropdownClass }); } render() { return React.createElement( "ul", { id: "site-header-user-menu-container" }, React.createElement( "li", { ref: node => this.node = node, id: "user-menu-toggle", className: this.state.dropdownClass }, React.createElement( "a", { className: "profile-menu-toggle" }, React.createElement("img", { className: "profile-menu-image", src: window.json_member_avatar }), React.createElement( "span", { className: "profile-menu-username" }, this.props.user.username ) ), React.createElement( "ul", { id: "user-profile-menu" }, React.createElement("div", { className: "dropdown-header" }), React.createElement( "li", null, React.createElement( "a", - { href: "/product/add" }, + { href: window.json_baseurl + "product/add" }, "Add Product" ) ), React.createElement( "li", null, React.createElement( "a", - { href: window.json_baseurl + "/u/" + this.props.user.username + "/products" }, + { href: window.json_baseurl + "u/" + this.props.user.username + "/products" }, "Products" ) ), React.createElement( "li", null, React.createElement( "a", - { href: window.json_baseurl + "/u/" + this.props.user.username + "/plings" }, + { href: window.json_baseurl + "u/" + this.props.user.username + "/plings" }, "Plings" ) ), React.createElement( "li", null, React.createElement( "a", - { href: "/settings" }, + { href: window.json_baseurl + "settings" }, "Settings" ) ), React.createElement( "li", null, React.createElement( "a", - { href: "/logout" }, + { href: window.json_logouturl }, "Logout" ) ) ) ) ); } } class MobileSiteHeader extends React.Component { constructor(props) { super(props); this.state = { status: "switch" }; this.showMobileUserMenu = this.showMobileUserMenu.bind(this); this.showMobileSearchForm = this.showMobileSearchForm.bind(this); this.showMobileSwitchMenu = this.showMobileSwitchMenu.bind(this); } showMobileUserMenu() { this.setState({ status: "user" }); } showMobileSearchForm() { this.setState({ status: "search" }); } showMobileSwitchMenu() { this.setState({ status: "switch" }); } render() { const menuItemCssClass = { "borderColor": this.props.template['header-nav-tabs']['border-color'], "backgroundColor": this.props.template['header-nav-tabs']['background-color'] }; const closeMenuElementDisplay = React.createElement( "a", { className: "menu-item", onClick: this.showMobileSwitchMenu }, React.createElement("span", { className: "glyphicon glyphicon-remove" }) ); let mobileMenuDisplay; if (this.state.status === "switch") { mobileMenuDisplay = React.createElement( "div", { id: "switch-menu" }, React.createElement( "a", { className: "menu-item", onClick: this.showMobileSearchForm, id: "user-menu-switch" }, React.createElement("span", { className: "glyphicon glyphicon-search" }) ), React.createElement( "a", { className: "menu-item", onClick: this.showMobileUserMenu, id: "search-menu-switch" }, React.createElement("span", { className: "glyphicon glyphicon-option-horizontal" }) ) ); } else if (this.state.status === "user") { mobileMenuDisplay = React.createElement( "div", { id: "mobile-user-menu" }, React.createElement( "div", { className: "menu-content-wrapper" }, React.createElement(MobileUserContainer, { user: this.props.user, baseUrl: this.props.baseUrl, serverUrl: this.state.serverUrl, template: this.props.template, redirectString: this.props.redirectString }) ), closeMenuElementDisplay ); } else if (this.state.status === "search") { mobileMenuDisplay = React.createElement( "div", { id: "mobile-search-menu" }, React.createElement( "div", { className: "menu-content-wrapper" }, React.createElement(SiteHeaderSearchForm, { baseUrl: this.props.baseUrl, searchBaseUrl: this.props.searchBaseUrl }) ), closeMenuElementDisplay ); } let logoElementCssClass = this.props.store.name; if (this.state.status !== "switch") { logoElementCssClass += " mini-version"; } return React.createElement( "section", { id: "mobile-site-header" }, React.createElement( "div", { id: "mobile-site-header-logo", className: logoElementCssClass }, React.createElement( "a", { href: this.props.logoLink }, React.createElement("img", { src: this.props.template['header-logo']['image-src'] }) ) ), React.createElement( "div", { id: "mobile-site-header-menus-container" }, mobileMenuDisplay ) ); } } class MobileUserContainer extends React.Component { constructor(props) { super(props); this.state = {}; } render() { let userDisplay; if (this.props.user) { userDisplay = React.createElement(SiteHeaderUserMenu, { serverUrl: this.state.serverUrl, baseUrl: this.state.baseUrl, user: this.props.user }); } else { userDisplay = React.createElement(SiteHeaderLoginMenu, { user: this.props.user, baseUrl: this.props.baseUrl, template: this.props.template, redirectString: this.props.redirectString }); } return React.createElement( "div", { id: "mobile-user-container" }, userDisplay ); } } ReactDOM.render(React.createElement(SiteHeader, null), document.getElementById('site-header-container')); diff --git a/sql_code/20190214_store_config_stay_in_context.sql b/sql_code/20190214_store_config_stay_in_context.sql new file mode 100644 index 000000000..8e180f39d --- /dev/null +++ b/sql_code/20190214_store_config_stay_in_context.sql @@ -0,0 +1,7 @@ +ALTER TABLE `config_store` + ADD COLUMN `stay_in_context` INT(1) NULL DEFAULT 0 AFTER `render_view_postfix`; + +UPDATE config_store s +SET s.stay_in_context = 0 +WHERE s.stay_in_context IS NULL; +