public function translate($string)
 {
     if ($this->environment) {
         return $this->environment->translate($string);
     }
     return $string;
 }
Esempio n. 2
0
 /**
  * Sharer constructor.
  * @param SocialSharing_Projects_Project $project
  * @param Rsc_Environment $environment
  */
 public function __construct(SocialSharing_Projects_Project $project, Rsc_Environment $environment)
 {
     $this->project = $project;
     $this->environment = $environment;
     $this->builder = $environment->getModule('HtmlBuilder');
     $this->dispatcher = $environment->getDispatcher();
 }
 public function __construct()
 {
     if (!class_exists('Rsc_Autoloader', false)) {
         require dirname(dirname(__FILE__)) . '/vendor/Rsc/Autoloader.php';
         Rsc_Autoloader::register();
     }
     $pluginPath = dirname(dirname(__FILE__));
     $environment = new Rsc_Environment('sss', '0.1', $pluginPath);
     /* Configure */
     $environment->configure(array('optimizations' => 1, 'environment' => $this->getPluginEnvironment(), 'default_module' => 'projects', 'lang_domain' => 'social_sharing', 'lang_path' => plugin_basename(dirname(__FILE__)) . '/langs', 'plugin_prefix' => 'SocialSharing', 'plugin_source' => $pluginPath . '/src', 'plugin_menu' => array('page_title' => __('Social Share by Supsystic', 'supsystic-social-sharing'), 'menu_title' => __('Social Share by Supsystic', 'supsystic-social-sharing'), 'capability' => 'manage_options', 'menu_slug' => 'supsystic-social-sharing', 'icon_url' => 'dashicons-share', 'position' => '101.8'), 'shortcode_name' => 'grid-gallery', 'db_prefix' => 'supsystic_ss_', 'hooks_prefix' => 'supsystic_ss_', 'ajax_url' => admin_url('admin-ajax.php'), 'admin_url' => admin_url(), 'uploads_rw' => true, 'jpeg_quality' => 95, 'plugin_db_update' => true, 'revision' => 130));
     $this->environment = $environment;
 }
Esempio n. 4
0
 public function __construct()
 {
     if (!class_exists('Rsc_Autoloader', false)) {
         require dirname(dirname(__FILE__)) . '/vendor/Rsc/Autoloader.php';
         Rsc_Autoloader::register();
     }
     $pluginPath = dirname(dirname(__FILE__));
     $environment = new Rsc_Environment('st', '1.0.8', $pluginPath);
     /* Configure */
     $environment->configure(array('optimizations' => 1, 'environment' => $this->getPluginEnvironment(), 'default_module' => 'tables', 'lang_domain' => 'supsystic_tables', 'lang_path' => plugin_basename(dirname(__FILE__)) . '/langs', 'plugin_prefix' => 'SupsysticTables', 'plugin_source' => $pluginPath . '/src', 'plugin_menu' => array('page_title' => __('Tables by Supsystic', 'supsystic-tables'), 'menu_title' => __('Tables by Supsystic', 'supsystic-tables'), 'capability' => 'manage_options', 'menu_slug' => 'supsystic-tables', 'icon_url' => '', 'position' => '102.2'), 'shortcode_name' => defined('SUPSYSTIC_TABLES_SHORTCODE_NAME') ? SUPSYSTIC_TABLES_SHORTCODE_NAME : 'supsystic-tables', 'db_prefix' => 'supsystic_tbl_', 'hooks_prefix' => 'supsystic_tbl_', 'ajax_url' => admin_url('admin-ajax.php'), 'admin_url' => admin_url(), 'plugin_db_update' => true, 'revision_key' => '_supsystic_tables_rev', 'revision' => 11));
     $this->environment = $environment;
 }
Esempio n. 5
0
 /**
  * Builds the model name.
  * @param string $model
  * @param string|Rsc_Mvc_Module $module
  * @return string
  */
 protected function getClassName($model, $module)
 {
     if (!$module) {
         $module = $model;
     }
     if ($module instanceof Rsc_Mvc_Module) {
         $module = $module->getModuleName();
     }
     $prefix = $this->environment->getConfig()->get('plugin_prefix');
     $className = $prefix . '_' . ucfirst($module) . '_Model_' . ucfirst($model);
     return $className;
 }
 /**
  * Creates new response
  * @param string $template The name of the template
  * @param array $data An associative array of the data
  * @return Rsc_Http_Response
  */
 public function response($template, array $data = array())
 {
     if ($template != Rsc_Http_Response::AJAX) {
         try {
             $twig = $this->environment->getTwig();
             $content = $twig->render($template, $data);
         } catch (Exception $e) {
             wp_die($e->getMessage());
         }
     } else {
         wp_send_json($data);
     }
     return Rsc_Http_Response::create()->setContent($content);
 }
Esempio n. 7
0
 /**
  * Builds the model name.
  * @param string $model
  * @param string|Rsc_Mvc_Module $module
  * @param string $prefix
  * @return string
  */
 protected function getClassName($model, $module, $prefix = null)
 {
     if (null === $prefix) {
         $prefix = $this->environment->getConfig()->get('plugin_prefix');
     }
     if (!$module) {
         $module = $model;
     }
     if (is_object($module) && $module instanceof Rsc_Mvc_Module) {
         $e = explode('_', get_class($module));
         $prefix = array_shift($e);
         $module = $module->getModuleName();
     }
     $className = $prefix . '_' . ucfirst($module) . '_Model_' . ucfirst($model);
     return $className;
 }
Esempio n. 8
0
 /**
  * Applies the filters the the query results.
  * Method builds the name like %hooks_prefix%%table_name%_%name%.
  * @param string $name Filter name
  * @param mixed $result Query result
  * @return mixed
  */
 protected function dispatchFilter($name, $result)
 {
     if (!$this->environment) {
         return $result;
     }
     return $this->environment->getDispatcher()->apply($this->getRawTableName() . '_' . strtolower($name), array($result));
 }
Esempio n. 9
0
 /**
  * Returns plugin code.
  *
  * @return string|null
  */
 public function getCode()
 {
     if (!$this->environment) {
         return null;
     }
     return $this->environment->getPluginName();
 }
Esempio n. 10
0
 /**
  * Creates new instance of the builder for the current project.
  * @return \SocialSharing_Projects_Builder
  */
 protected function instantiateBuilder()
 {
     $builder = null;
     if ('flat' === substr($this->project->get('design', 'flat-1'), 0, 4)) {
         $builder = new SocialSharing_Projects_Builder_Flat($this->project, $this->environment);
     } elseif (class_exists('SocialSharingPro_Projects_Builder_Mono') && 'mono' === substr($this->project->get('design'), 0, 4)) {
         $builder = new SocialSharingPro_Projects_Builder_Mono($this->project, $this->environment);
     } elseif (class_exists('SocialSharingPro_Projects_Builder_Bordered') && 'bordered' === substr($this->project->get('design'), 0, 8)) {
         $builder = new SocialSharingPro_Projects_Builder_Bordered($this->project, $this->environment);
     } elseif (class_exists('SocialSharingPro_Projects_Builder_Livejournal') && 'livejournal' === substr($this->project->get('design'), 0, 11)) {
         $builder = new SocialSharingPro_Projects_Builder_Livejournal($this->project, $this->environment);
     } elseif (class_exists('SocialSharingPro_Projects_Builder_Various') && 'various' === substr($this->project->get('design'), 0, 7)) {
         $builder = new SocialSharingPro_Projects_Builder_Various($this->project, $this->environment);
     } else {
         $this->project->setSettings(array_merge($this->project->getSettings(), array('design' => 'flat-1')));
         $builder = new SocialSharing_Projects_Builder_Flat($this->project, $this->environment);
         add_action('admin_notices', array($this, 'invalidBuilderNotice'));
     }
     /** @var SocialSharing_Networks_Module $networks */
     if ($this->project->has('show_more') && null !== ($networks = $this->environment->getModule('networks'))) {
         $builder = new SocialSharing_Projects_Builder_Decorator_Popup($builder, $networks->getAll());
         /** @var SocialSharing_Ui_Module $ui */
         $ui = $this->environment->getModule('ui');
         $ui->addAsset($ui->create('script', 'social-sharing-builder-popup')->setHookName('before_html_build')->setModuleSource($this->environment->getModule('projects'), 'js/builder/popup.js')->setCachingAllowed($this->environment->isProd()));
         $ui->addAsset($ui->create('style', 'social-sharing-builder-popup')->setHookName('before_html_build')->setModuleSource($this->environment->getModule('projects'), 'css/builder/popup.css')->setCachingAllowed($this->environment->isProd()));
     }
     if ($this->project->has('sidebar_navigation')) {
         $builder = new SocialSharing_Projects_Builder_Decorator_Navigation($builder);
         /** @var SocialSharing_Ui_Module $ui */
         $ui = $this->environment->getModule('ui');
         $ui->addAsset($ui->create('script', 'social-sharing-builder-navigation')->setHookName('before_html_build')->setModuleSource($this->environment->getModule('projects'), 'js/builder/navigation.js')->setCachingAllowed($this->environment->isProd()));
         $ui->addAsset($ui->create('style', 'social-sharing-builder-navigation')->setHookName('before_html_build')->setModuleSource($this->environment->getModule('projects'), 'css/builder/navigation.css')->setCachingAllowed($this->environment->isProd()));
     }
     return $builder;
 }
Esempio n. 11
0
 /**
  * @param Rsc_Http_Parameters $method
  * @return bool
  */
 public function handleRequest(Rsc_Http_Parameters $method)
 {
     /** @var Rsc_Mvc_Module $module */
     if (!$method->has('route')) {
         return false;
     }
     $route = $method->get('route');
     $module = isset($route['module']) ? $route['module'] : $this->environment->getConfig()->get('default_module');
     $action = isset($route['action']) ? $route['action'] : 'index';
     if (null !== ($module = $this->environment->getModule(strtolower($module)))) {
         $controller = $module->getController();
         if ($controller !== null && method_exists($controller, $action = sprintf('%sAction', $action))) {
             return call_user_func_array(array($controller, $action), array($controller->getRequest()));
         }
     }
     return false;
 }
Esempio n. 12
0
 public function handle()
 {
     $action = $this->request->query->get('action', 'index') . 'Action';
     if (method_exists($this->getController(), $action)) {
         return call_user_func_array(array($this->getController(), $action), array($this->request));
     }
     $twig = $this->environment->getTwig();
     return Rsc_Http_Response::create()->setContent($twig->render('404.twig'));
 }
 /**
  * Creates plugin's directories.
  */
 protected function initFilesystem()
 {
     $directories = array('tmp' => '/grid-gallery', 'log' => '/grid-gallery/log', 'cache' => '/grid-gallery/cache', 'cache_galleries' => '/grid-gallery/cache/galleries', 'cache_twig' => '/grid-gallery/cache/twig');
     foreach ($directories as $key => $dir) {
         if (false !== ($fullPath = $this->makeDirectory($dir))) {
             $this->environment->getConfig()->add('plugin_' . $key, $fullPath);
         }
     }
 }
 /**
  * Creates plugin's directories.
  */
 protected function initFilesystem()
 {
     $directories = array('tmp' => '/supsystic-slider', 'log' => '/supsystic-slider/log', 'cache' => '/supsystic-slider/cache', 'twig_cache' => '/supsystic-slider/cache/twig');
     foreach ($directories as $key => $dir) {
         if (false !== ($fullPath = $this->makeDirectory($dir))) {
             $this->environment->getConfig()->add('plugin_' . $key, $fullPath);
         }
     }
 }
Esempio n. 15
0
 /**
  * Removes photos with specified folder id.
  *
  * @param int $id Folder id.
  * @return bool
  */
 public function deleteByFolderId($id)
 {
     if ($this->deleteBy('folder_id', $id)) {
         if ($this->environment) {
             $this->environment->getDispatcher()->dispatch('photos_delete_by_folder_id', array($id));
         }
         return true;
     }
     return false;
 }
Esempio n. 16
0
 /**
  * Extends the slider object with required properties.
  *
  * @param stdClass[]|stdClass $slider Slider object
  * @throws RuntimeException
  * @return stdClass[]|stdClass
  */
 public function compile($slider)
 {
     if (is_array($slider)) {
         return array_map(array($this, 'compile'), $slider);
     }
     if (!$this->environment) {
         throw new RuntimeException('Environment is not specified.');
     }
     $dispatcher = $this->environment->getDispatcher();
     if (!$slider) {
         return;
     }
     return $dispatcher->apply(self::EVENT_COMPILE, array($slider));
 }
Esempio n. 17
0
 /**
  * Returns an array of found modules or NULL if at least one module did not found
  * @return array|null
  */
 public function getModulesList()
 {
     if (!$this->modulesList) {
         $modulesList = array();
         $modulesLocation = array(array(dirname(dirname(__FILE__)), 'Rsc'), array($this->environment->getConfig()->get('plugin_source'), $this->environment->getConfig()->get('plugin_prefix')));
         foreach ($modulesLocation as $locationData) {
             if (!in_array(null, $locationData) && count($locationData) == 2) {
                 list($path, $prefix) = $locationData;
                 $modules = $this->findModules($path, $prefix);
                 if (is_array($modules) && count($modules) > 0) {
                     $modulesList = array_merge($modulesList, $modules);
                 }
             }
         }
         $this->modulesList = new Rsc_Common_Collection($modulesList);
     }
     return $this->modulesList;
 }
Esempio n. 18
0
 public function handle()
 {
     $action = $this->request->query->get('action', 'index') . 'Action';
     $welcomePageShowed = $this->environment->getConfig()->get('welcome_page_was_showed');
     $promoController = $this->environment->getConfig()->get('promo_controller');
     if ($promoController && class_exists($promoController) && !$welcomePageShowed) {
         $promoController = new $promoController($this->environment, $this->request);
         if (method_exists($promoController, 'indexAction')) {
             return call_user_func_array(array($promoController, 'indexAction'), array($this->request));
         }
     } else {
         if (method_exists($this->getController(), $action)) {
             return call_user_func_array(array($this->getController(), $action), array($this->request));
         }
     }
     $twig = $this->environment->getTwig();
     return Rsc_Http_Response::create()->setContent($twig->render('404.twig'));
 }
Esempio n. 19
0
 /**
  * Returns HtmlBuilder module
  * @return SocialSharing_HtmlBuilder_Module
  */
 protected function getBuilder()
 {
     return $this->environment->getModule('HtmlBuilder');
 }