Beispiel #1
0
 /**
  * Instance construct
  */
 public function __construct()
 {
     $this->language = PhalconDI::getDefault()->get('config')->website->language;
     global $APP_LOCATION;
     if ($APP_LOCATION) {
         $cache = ZCache::getInstance();
         $translation = $cache->get('ZCMS_Core_ZTranslate' . $APP_LOCATION);
         if ($translation === null) {
             $modules = get_child_folder(ROOT_PATH . "/app/{$APP_LOCATION}/");
             $this->addLang(ROOT_PATH . '/app/languages/en-GB/en-GB.php');
             $this->addLang(ROOT_PATH . '/app/languages/' . $this->language . '/' . $this->language . '.php');
             $this->addModuleLang($modules, $APP_LOCATION);
             $cache->save('ZCMS_Core_ZTranslate', $this->translation);
         } else {
             $this->setTranslate($translation);
         }
     }
 }
Beispiel #2
0
 /**
  * Update All Module
  *
  * @param bool $redirect
  */
 public function updateAction($redirect = true)
 {
     //Get All Module
     $allModulesBackEnd = get_child_folder(APP_DIR . '/backend/');
     $allModulesFrontEnd = get_child_folder(APP_DIR . '/frontend/');
     $allModules = array_merge($allModulesBackEnd, $allModulesFrontEnd);
     $allModulesUnique = array_unique($allModules);
     //Module in frontend and backend is duplicate!
     if (count($allModulesUnique) != count($allModules)) {
         if ($redirect) {
             $this->flashSession->notice('m_system_message_module_in_frontend_and_backend_is_duplicate');
         }
         $this->response->redirect('/admin/system/user/');
         die(__('m_system_message_module_in_frontend_and_backend_is_duplicate'));
     } else {
         $this->deleteModuleNotExists($allModulesUnique);
         $allModulesBackEndReturn = $this->updateModuleInfo($allModulesBackEnd, 'backend');
         $allModulesFrontEndReturn = $this->updateModuleInfo($allModulesFrontEnd, 'frontend');
         $return = array_merge_recursive($allModulesBackEndReturn, $allModulesFrontEndReturn);
         if ($redirect) {
             if (isset($return['success'])) {
                 $this->flashSession->success(__('m_system_module_message_items_module_update_information_successfully', ['1' => count($return['success'])]));
             }
             if (isset($return['error'])) {
                 $message = [];
                 foreach ($return['error'] as $error) {
                     $message[] = '<strong>' . $error[0] . '</strong> [' . $error[1] . ']';
                 }
                 $this->flashSession->error(__("m_system_module_message_resource_for_module_error_json", ['1' => implode(',', $message)]));
             }
         }
     }
     UserRoles::updateModuleMenu();
     if ($redirect) {
         $this->response->redirect('/admin/system/module/');
     }
 }
Beispiel #3
0
 /**
  * Update widget info
  */
 protected final function updateInfoAllWidget()
 {
     $allWidget = get_child_folder(APP_DIR . '/widgets/frontend/');
     ZTranslate::getInstance()->addWidgetLang($allWidget, 'frontend');
     $this->deleteOldWidget($allWidget);
     foreach ($allWidget as $w) {
         $widgetPath = APP_DIR . '/widgets/frontend/' . $w . '/' . $w . '.php';
         $infoWidget = get_widget_data($widgetPath);
         $infoWidget['title'] = $infoWidget['name'];
         $widget = CoreWidgets::findFirst(['conditions' => 'base_name = ?0', 'bind' => [0 => $w]]);
         if (!$widget) {
             $widget = new CoreWidgets();
             $widget->base_name = $w;
             $widget->published = 0;
             $widget->is_core = 0;
         }
         $keys = ['title', 'description', 'version', 'author', 'uri', 'authorUri', 'location'];
         foreach ($keys as $key) {
             $widget->{$key} = $infoWidget[$key];
         }
         if (isset($widget->location) && (strtolower($widget->location) == 'frontend' || strtolower($widget->location) == 'backend')) {
             $widget->location = strtolower($widget->location);
         } else {
             $widget->location = 'frontend';
         }
         $widget->save();
     }
 }
Beispiel #4
0
 /**
  * @param CoreConfigs $data
  */
 public function initialize($data = null)
 {
     $allConfig = CoreConfigs::find()->toArray();
     $isCryptOfAllKey = [];
     foreach ($allConfig as $conf) {
         $isCryptOfAllKey[$conf['key']] = $conf['is_crypt_value'];
     }
     if ($data != null) {
         $allKeyData = get_object_vars($data);
         foreach ($allKeyData as $key => $value) {
             if ($isCryptOfAllKey[$key] == 1) {
                 $data->{$key} = '';
             }
         }
     }
     //Section Website
     $debug = new Select('debug', [0 => __('gb_off'), 1 => __('gb_on')]);
     $debug->addValidator(new InclusionIn(['domain' => ['0', '1']]));
     $this->add($debug);
     $baseUri = new Text('baseUri');
     $this->add($baseUri);
     $metaDesc = new TextArea("metadesc", ['rows' => 4]);
     $this->add($metaDesc);
     $metaKey = new TextArea("metakey");
     $this->add($metaKey);
     $siteName = new Text("sitename");
     $this->add($siteName);
     $direction = new Select('direction', ['ltr' => 'Left to right', 'rtl' => 'Right to Left']);
     $this->add($direction);
     $timezone = new Select('timezone', array_combine(timezone_identifiers_list(), timezone_identifiers_list()));
     $this->add($timezone);
     //$CoreLanguages = CoreLanguages::find(['columns' => 'language_code, title', 'order' => 'language_code']);
     $CoreLanguages = CoreLanguages::find(['order' => 'language_code']);
     $language = new Select('language', $CoreLanguages, ['using' => ['language_code', 'title']]);
     $this->add($language);
     $limit = new Text('limit');
     $limit->addValidator(new Between(['minimum' => 0, 'maximum' => 100, 'message' => 'm_system_module_message_the_limit_must_be_between_1_100']));
     $this->add($limit);
     $media_limit = new Text('media_limit');
     $media_limit->addValidator(new Regex(['pattern' => '/[0-9]+(\\.[0-9]+)?/', 'message' => 'm_system_config_message_this_field_must_be_a_number']));
     $media_limit->addValidator(new Between(['minimum' => 0, 'maximum' => 100, 'message' => 'm_system_module_message_the_media_limit_must_be_between_1_100']));
     $this->add($media_limit);
     $feed_limit = new Text('feed_limit');
     $feed_limit->addValidator(new Regex(['pattern' => '/[0-9]+(\\.[0-9]+)?/', 'message' => 'm_system_config_message_this_field_must_be_a_number']));
     $feed_limit->addValidator(new Between(['minimum' => 0, 'maximum' => 100, 'message' => 'm_system_module_message_the_media_limit_must_be_between_1_100']));
     $this->add($feed_limit);
     //Section memcache
     $mem_cache_status = new Select('mem_cache_status', [0 => __('gb_off'), 1 => __('gb_on')]);
     $mem_cache_status->addValidator(new InclusionIn(['domain' => ['0', '1']]));
     $this->add($mem_cache_status);
     $mem_cache_host = new Text('mem_cache_host');
     $this->add($mem_cache_host);
     $mem_cache_lifetime = new Text('mem_cache_lifetime');
     $this->add($mem_cache_lifetime);
     $mem_cache_prefix = new Text('mem_cache_prefix');
     $this->add($mem_cache_prefix);
     $mem_cache_port = new Text('mem_cache_port');
     $mem_cache_port->addValidator(new Regex(['pattern' => '/[0-9]+(\\.[0-9]+)?/', 'message' => 'm_system_module_message_the_memcache_port_must_be_a_number']));
     $this->add($mem_cache_port);
     //Section apc cache
     $apc_prefix = new Text('apc_prefix');
     $this->add($apc_prefix);
     $apc_lifetime = new Text('apc_lifetime');
     $this->add($apc_lifetime);
     $apc_status = new Select('apc_status', [0 => __('gb_off'), 1 => __('gb_on')]);
     $apc_status->addValidator(new InclusionIn(['domain' => ['0', '1']]));
     $this->add($apc_status);
     //Section Mail
     /**
      * <code>
      * <select id="mail_type" name="mail_type" class="form-control">
      *    <option value="mail">Mail</option>
      *    <option selected="selected" value="smtp">SMTP</option>
      *    <option value="sendmail">SendMail</option>
      * </select>
      * </code>
      */
     $mail_type = new Select('mail_type', ['mail' => __('m_system_config_label_mail_type_value_mail'), 'smtp' => __('m_system_config_label_mail_type_value_smtp'), 'sendmail' => __('m_system_config_label_mail_type_value_sendmail')]);
     $mail_type->addValidator(new InclusionIn(['domain' => ['mail', 'smtp', 'sendmail']]));
     $this->add($mail_type);
     $mail_from = new Text('mail_from');
     $this->add($mail_from);
     $from_name = new Text('from_name');
     $this->add($from_name);
     $send_mail = new Text('send_mail');
     $this->add($send_mail);
     $smtp_user = new Text('smtp_user');
     $this->add($smtp_user);
     $smtp_pass = new Password('smtp_pass');
     $this->add($smtp_pass);
     $smtp_host = new Text('smtp_host');
     $this->add($smtp_host);
     $smtp_secure = new Select('smtp_secure', ['ssl' => 'SSL', 'tsl' => 'TSL']);
     $smtp_secure->addValidator(new InclusionIn(['domain' => ['ssl', 'tsl']]));
     $this->add($smtp_secure);
     $smtp_port = new Text('smtp_port');
     $smtp_port->addValidator(new Regex(['pattern' => '/[0-9]+(\\.[0-9]+)?/', 'message' => 'm_system_module_message_the_smtp_port_must_be_a_number']));
     $this->add($smtp_port);
     $smtp_auth = new Text('smtp_auth');
     $smtp_auth->addValidator(new Regex(['pattern' => '/[0-9]+(\\.[0-9]+)?/', 'message' => 'm_system_module_message_the_smtp_auth_must_be_a_number']));
     $this->add($smtp_auth);
     //Section log
     $log = new Select('log', ['0' => __('gb_off'), '1' => __('gb_on')]);
     $log->addValidator(new InclusionIn(['domain' => ['0', '1']]));
     $this->add($log);
     $log_type = new Select('log_type', ['file' => __('m_system_config_label_database_file'), 'database' => __('m_system_config_label_database')]);
     $log_type->addValidator(new InclusionIn(['domain' => ['file', 'database']]));
     $this->add($log_type);
     $auth_lifetime = new Text('auth_lifetime');
     $auth_lifetime->addValidator(new Regex(['pattern' => '/[0-9]+(\\.[0-9]+)?/', 'message' => 'm_system_module_message_the_auth_lifetime_must_be_a_number']));
     $this->add($auth_lifetime);
     //Section Template
     //Add translation template
     ZTranslate::getInstance()->addTemplateLang(get_child_folder(APP_DIR . '/templates/backend'));
     ZTranslate::getInstance()->addTemplateLang(get_child_folder(APP_DIR . '/templates/frontend'), 'frontend');
     //Backend default template
     $backendTemplateArray = CoreTemplates::find("location = 'backend'")->toArray();
     $backendTemplateBaseName = array_column($backendTemplateArray, 'base_name');
     $backendTemplate = array_combine($backendTemplateBaseName, array_map('__', array_column($backendTemplateArray, 'name')));
     $defaultTemplate = new Select('defaultTemplate', $backendTemplate);
     $defaultTemplate->addValidator(new InclusionIn(['domain' => $backendTemplateBaseName]));
     $this->add($defaultTemplate);
     //Backend compile template
     $compileTemplate = new Select('compileTemplate', ['0' => __('gb_off'), '1' => __('gb_on')]);
     $compileTemplate->addValidator(new InclusionIn(['domain' => ['0', '1']]));
     $this->add($compileTemplate);
     //Frontend default template
     $frontendTemplateArray = CoreTemplates::find("location = 'frontend'")->toArray();
     $frontendTemplateBaseName = array_column($frontendTemplateArray, 'base_name');
     $frontendTemplate = array_combine($frontendTemplateBaseName, array_map('__', array_column($frontendTemplateArray, 'name')));
     $defaultTemplate = new Select('defaultTemplate', $frontendTemplate);
     $defaultTemplate->addValidator(new InclusionIn(['domain' => $frontendTemplateBaseName]));
     $this->add($defaultTemplate);
     //Frontend compile template
     $compileTemplate = new Select('compileTemplate', ['0' => __('gb_off'), '1' => __('gb_on')]);
     $compileTemplate->addValidator(new InclusionIn(['domain' => ['0', '1']]));
     $this->add($compileTemplate);
     //Shipping
     $shipping = new Text('sender_id');
     $this->add($shipping);
     $shipping = new Text('sender_name');
     $this->add($shipping);
     $shipping = new Text('sender_contact_name');
     $this->add($shipping);
     $shipping = new Text('sender_contact_phone');
     $this->add($shipping);
     $shipping = new Text('sender_address_1');
     $this->add($shipping);
     $shipping = new Text('sender_address_2');
     $this->add($shipping);
     $shipping = new Text('sender_town');
     $this->add($shipping);
     $shipping = new Text('sender_state');
     $this->add($shipping);
     $shipping = new Text('sender_post_code');
     $this->add($shipping);
     $shipping = new Text('sender_country');
     $this->add($shipping);
     $shipping = new Text('toll_slid');
     $this->add($shipping);
     $shipping = new Text('toll_service_name');
     $this->add($shipping);
     $shipping = new Text('toll_service_code');
     $this->add($shipping);
     $shipping = new Text('toll_email_transmission');
     $this->add($shipping);
     $shipping = new Text('toll_system_transmission_id');
     $this->add($shipping);
     $shipping = new Text('line_weight');
     $this->add($shipping);
     $shipping = new Text('charge_account');
     $this->add($shipping);
     //Payment get way
     $merchant_number = new Text('merchant_number');
     $this->add($merchant_number);
     $merchant_number = new Text('merchant_username');
     $this->add($merchant_number);
     $merchant_number = new Password('merchant_password');
     $this->add($merchant_number);
     $merchant_number = new Text('merchant_referrence');
     $this->add($merchant_number);
     $merchant_number = new Text('link_authorize');
     $this->add($merchant_number);
     $merchant_number = new Text('link_pay_request');
     $this->add($merchant_number);
     $merchant_number = new Text('link_verify');
     $this->add($merchant_number);
     $merchant_number = new Text('link_pay_shop');
     $this->add($merchant_number);
     $payment_return_url = new Text('return_url');
     $this->add($payment_return_url);
 }
Beispiel #5
0
/**
 * Load all widget file
 *
 * @param string $location
 */
function zcms_load_widget_file($location = 'frontend')
{
    $allWidget = get_child_folder(APP_DIR . "/widgets/{$location}/");
    foreach ($allWidget as $w) {
        $widgetPath = APP_DIR . "/widgets/{$location}/" . $w . '/' . $w . '.php';
        if (file_exists($widgetPath)) {
            require_once $widgetPath;
        } elseif (DEBUG) {
            /**
             * @var \Phalcon\Flash\Session $flashSession
             */
            $flashSession = PDI::getDefault()->get('flashSession');
            $flashSession->error(__('gb_widget_not_found_in_location', ['1' => $w, '2' => $location]));
        }
    }
}
Beispiel #6
0
 /**
  * Add new widget
  *
  * @return string Ajax
  */
 public function addNewWidgetAction()
 {
     $response = new PResponse();
     $content = '';
     $response->setHeader("Content-Type", "application/json");
     if ($this->request->isAjax()) {
         //Add widget frontend translation
         $allWidget = get_child_folder(APP_DIR . '/widgets/frontend/');
         ZTranslate::getInstance()->addWidgetLang($allWidget, 'frontend');
         /**
          * @var CoreTemplates $defaultFrontEndTemplate
          */
         $defaultFrontEndTemplate = CoreTemplates::findFirst("location = 'frontend' AND published = 1");
         $theme_name = $defaultFrontEndTemplate->base_name;
         $widget_class = $this->request->getPost('widget_class', 'string', '');
         $index = $this->request->getPost('index', 'int', 1);
         $sidebar_name = $this->request->getPost('sidebar_name', 'string', '');
         $CoreSidebars = CoreSidebars::findFirst(['conditions' => 'sidebar_base_name = ?1 AND theme_name = ?2 AND location = ?3', 'bind' => [1 => $sidebar_name, 2 => $theme_name, 3 => 'frontend']]);
         if (!$CoreSidebars) {
             $CoreSidebars = new CoreSidebars();
             $CoreSidebars->sidebar_base_name = $sidebar_name;
             $CoreSidebars->theme_name = $theme_name;
             $CoreSidebars->location = 'frontend';
             $CoreSidebars->save();
         }
         if (is_object($CoreSidebars) && $CoreSidebars) {
             try {
                 /**
                  * @var ZWidget $widget
                  */
                 $widget = new $widget_class();
                 $widget->save($sidebar_name, $index, null, $theme_name);
                 $content = $widget->getForm(true);
             } catch (Exception $e) {
             }
         }
     }
     $response->setJsonContent($content);
     return $response;
 }
Beispiel #7
0
 private function updateRules()
 {
     //Get active module
     $core_module = CoreModules::find("published = 1 AND location = 'backend'");
     //Read resources
     foreach ($core_module as $cModule) {
         $filePath = APP_DIR . "/backend/" . $cModule->base_name . "/Resource.php";
         $module = str_replace(' ', "", $cModule->base_name);
         //Save rules from resource.php to database
         $resource = check_resource($filePath, $cModule->base_name, 'backend');
         if ($resource) {
             //Save rules
             $rules = $resource["rules"];
             foreach ($rules as $rule) {
                 $this->saveRule($resource, $module, $rule);
             }
             //Delete old rules
             $this->deleteOldRules($module, $rules);
         } else {
             $this->flashSession->error(__('m_system_role_message_resource_for_module_is_error', ["1" => $module]));
         }
     }
     //Get all module backend
     $allModuleBackEnd = get_child_folder(APP_DIR . '/backend/');
     foreach ($allModuleBackEnd as &$aMBE) {
         $aMBE = '"' . $aMBE . '"';
     }
     //Get old module to delete rules
     $allModuleNotExist = UserRules::find("module NOT IN(" . implode(",", $allModuleBackEnd) . ")")->toArray();
     /**
      * @var CoreModules[] $unpublished_module
      */
     $unpublished_module = CoreModules::find("published = 0 AND location='backend'");
     $arrayModuleName = [];
     if (count($unpublished_module) || count($allModuleNotExist)) {
         foreach ($unpublished_module as $u) {
             $arrayModuleName[] = "'" . $u->base_name . "'";
         }
         foreach ($allModuleNotExist as $aMNE) {
             $arrayModuleName[] = "'" . $aMNE['module'] . "'";
         }
         $arrayModuleName = array_unique($arrayModuleName);
         if (count($arrayModuleName)) {
             /**
              * @var UserRules[] $userRuleNeedDelete
              */
             $userRuleNeedDelete = UserRules::find("module in (" . implode(',', $arrayModuleName) . ")");
             if (count($userRuleNeedDelete)) {
                 $ids = [];
                 foreach ($userRuleNeedDelete as $aRND) {
                     $ids[] = $aRND->rule_id;
                 }
                 $deleteRuleQuery = "DELETE FROM user_role_mapping WHERE rule_id IN (" . implode(',', $ids) . ")";
                 $this->db->execute($deleteRuleQuery);
                 foreach ($userRuleNeedDelete as $aRND) {
                     $aRND->delete();
                 }
             }
         }
     }
 }
Beispiel #8
0
 /**
  * Add template language
  */
 private function _addTemplateLang()
 {
     $templates = get_child_folder(APP_DIR . '/templates/backend/');
     ZTranslate::getInstance()->addTemplateLang($templates);
     $templates = get_child_folder(APP_DIR . '/templates/frontend/');
     ZTranslate::getInstance()->addTemplateLang($templates, 'frontend');
 }