/**
  * Function: JS Draw SList
  *
  */
 public static function js_draw_sel_list($y_var_name, $y_options_arr, $y_size = '8')
 {
     //--
     $tmp_init_slist = "\n";
     //--
     $tmp_suffix = '_' . sha1('The-SList-JSComponent:@#' . $y_var_name);
     //--
     $options_html = '';
     //--
     if (is_array($y_options_arr)) {
         foreach ($y_options_arr as $key => $val) {
             // warehouses as arr[]=id
             if (strlen($key) > 0 and strlen($val) > 0) {
                 $options_html .= '<option value="' . \Smart::escape_html((string) $key) . '">' . \Smart::escape_html((string) $val) . '</option>';
             }
             //end if
         }
         //end foreach
     }
     //end if
     //--
     $translator_core_js_messages = \SmartTextTranslations::getTranslator('@core', 'js_messages');
     //--
     $tmp_slist = \SmartMarkersTemplating::render_file_template('modules/mod-js-components/views/js/jsjsslist/slist.inc.htm', array('SIZE' => (int) $y_size, 'VARIABLE_NAME' => \Smart::escape_html((string) $y_var_name), 'TXT_SELECT' => $translator_core_js_messages->text('btn_select'), 'TXT_RESET' => $translator_core_js_messages->text('btn_reset'), 'SLIST_SRC' => 'smartframeworkComponents_SList_SRC' . $tmp_suffix, 'SLIST_SEL' => 'smartframeworkComponents_SList_SEL' . $tmp_suffix, 'SLIST_VAL' => 'smartframeworkComponents_SList_VAL' . $tmp_suffix, 'OPTIONS' => $options_html), 'yes');
     //--
     return (string) $tmp_init_slist . $tmp_slist;
     //--
 }
Exemplo n.º 2
0
 private static function display_calendar($y_mode, $y_sel_date, $y_width, $y_highlight_selected, $y_events_arr)
 {
     //--
     global $configs;
     //--
     if ($configs['regional']['calendar-week-start'] == 1) {
         $the_first_day = 1;
         // Calendar Start on Monday
     } else {
         $the_first_day = 0;
         // Calendar Start on Sunday
     }
     //end if else
     //--
     if ((string) $y_sel_date == '') {
         $y_sel_date = date('Y-m-d');
     }
     //end if
     //--
     $translator_core_calendar = SmartTextTranslations::getTranslator('@core', 'calendar');
     //--
     $calendar = new SmartHTMLCalendar(date('Y-m-d', @strtotime($y_sel_date)), $y_highlight_selected, $y_width, (string) $y_mode);
     //-- set months
     $calendar->setMonthNames(array('01' => $translator_core_calendar->text('m_01'), '02' => $translator_core_calendar->text('m_02'), '03' => $translator_core_calendar->text('m_03'), '04' => $translator_core_calendar->text('m_04'), '05' => $translator_core_calendar->text('m_05'), '06' => $translator_core_calendar->text('m_06'), '07' => $translator_core_calendar->text('m_07'), '08' => $translator_core_calendar->text('m_08'), '09' => $translator_core_calendar->text('m_09'), '10' => $translator_core_calendar->text('m_10'), '11' => $translator_core_calendar->text('m_11'), '12' => $translator_core_calendar->text('m_12')));
     //-- set days
     if ((string) $y_mode == 'small') {
         $calendar->setDayNames(array(0 => SmartUnicode::sub_str($translator_core_calendar->text('w_1'), 0, 2), 1 => SmartUnicode::sub_str($translator_core_calendar->text('w_2'), 0, 2), 2 => SmartUnicode::sub_str($translator_core_calendar->text('w_3'), 0, 2), 3 => SmartUnicode::sub_str($translator_core_calendar->text('w_4'), 0, 2), 4 => SmartUnicode::sub_str($translator_core_calendar->text('w_5'), 0, 2), 5 => SmartUnicode::sub_str($translator_core_calendar->text('w_6'), 0, 2), 6 => SmartUnicode::sub_str($translator_core_calendar->text('w_7'), 0, 2)));
     } else {
         $calendar->setDayNames(array(0 => $translator_core_calendar->text('w_1'), 1 => $translator_core_calendar->text('w_2'), 2 => $translator_core_calendar->text('w_3'), 3 => $translator_core_calendar->text('w_4'), 4 => $translator_core_calendar->text('w_5'), 5 => $translator_core_calendar->text('w_6'), 6 => $translator_core_calendar->text('w_7')));
     }
     //end if else
     //-- set start on
     $calendar->setStartOfWeek($the_first_day);
     //--
     if (Smart::array_size($y_events_arr) > 0) {
         for ($i = 0; $i < count($y_events_arr); $i++) {
             if ($y_events_arr[$i]['date-end'] === false) {
                 $calendar->addDayEvent((string) $y_events_arr[$i]['event-html'], date('Y-m-d', @strtotime((string) $y_events_arr[$i]['date-start'])), false);
             } else {
                 $calendar->addDayEvent((string) $y_events_arr[$i]['event-html'], date('Y-m-d', @strtotime((string) $y_events_arr[$i]['date-start'])), date('Y-m-d', @strtotime((string) $y_events_arr[$i]['date-end'])));
             }
             //end if else
         }
         //end for
     }
     //end if
     //-- draw
     return '<div title="' . Smart::escape_html(date('Y-m', @strtotime((string) $y_sel_date))) . '">' . $calendar->draw() . '</div>';
     //--
 }
    /**
     * Display True=1/False=0 Selector
     *
     * @access 		private
     * @internal
     *
     * @param STRING $y_var			:: HTML Var Name
     * @param STRING $y_val			:: '' | '0' | '1'
     * @param STRING $ytxt_true		:: Text for 'Yes' (True=1)
     * @param STRING $ytxt_false	:: Text for 'No' (False=0)
     * @return STRING				:: HTML Code
     */
    public static function true_false_selector($y_var, $y_val)
    {
        //--
        $translator_core_messages = SmartTextTranslations::getTranslator('@core', 'messages');
        //--
        $txt_true = $translator_core_messages->text('yes');
        $txt_false = $translator_core_messages->text('no');
        //--
        if ((string) $y_val == '1') {
            $tmp_m = 'checked';
            $tmpx_code = $txt_true;
        } else {
            $tmp_f = 'checked';
            $tmpx_code = $txt_false;
        }
        //end if
        //--
        $code = <<<HTML_CODE
  {$txt_true}<input name="{$y_var}" type="radio" value="1" {$tmp_m}>
  &nbsp; &nbsp;
  {$txt_false}<input name="{$y_var}" type="radio" value="0" {$tmp_f}>
HTML_CODE;
        //--
        if ((string) $y_var == '') {
            $code = (string) $tmpx_code;
        }
        //end if
        //--
        return (string) $code;
        //--
    }
Exemplo n.º 4
0
 public function Run()
 {
     //-- sample page variable from Request (GET/POST)
     $some_var_from_request = $this->RequestVarGet('extra_text', 'default', 'string');
     //--
     //--
     $module_area = $this->ControllerGetParam('module-area');
     $the_lang = (string) $this->ConfigParamGet('regional.language-id');
     $the_xlang = (string) $this->ConfigParamGet('regional.language-id');
     // repeat this to check if caching works
     //--
     if ($this->IfDebug()) {
         $this->SetDebugData('Module Area', $module_area);
         $this->SetDebugData('Module Path', $this->ControllerGetParam('module-path'));
         $this->SetDebugData('Module Name', $this->ControllerGetParam('module-name'));
         $this->SetDebugData('URL Script', $this->ControllerGetParam('url-script'));
         $this->SetDebugData('URL Path', $this->ControllerGetParam('url-path'));
         $this->SetDebugData('URL Address', $this->ControllerGetParam('url-addr'));
         $this->SetDebugData('URL Page', $this->ControllerGetParam('url-page'));
         $this->SetDebugData('Config / Language ID', $the_lang);
     }
     //end if
     //--
     //--
     if ($this->PageCacheisActive()) {
         //-- because the Request can modify the content, also the unique key must take in account variables that will vary the page config or page content vars
         $the_page_cache_key = 'samples-toolkit-' . $module_area . '__' . SmartHashCrypto::sha384((string) $some_var_from_request);
         //--
     }
     //end if
     //--
     //--
     if ($this->PageCacheisActive()) {
         //--
         $test_cache = $this->PageGetFromCache('cached-samples', $the_page_cache_key);
         //--
         if (Smart::array_size($test_cache) > 0) {
             if (is_array($test_cache['configs']) && is_array($test_cache['vars'])) {
                 // if valid cache (test as we exported both arrays ... so they must be the 2 arrays again)
                 $this->PageViewSetCfgs((array) $test_cache['configs']);
                 $this->PageViewSetVars((array) $test_cache['vars']);
                 $this->PageViewAppendVar('main', "\n" . '<!-- Redis Cached Content Key: ' . Smart::escape_html($the_page_cache_key) . ' -->' . "\n");
                 // add a markup to the HTML to know was served from cache ...
                 if ($this->IfDebug()) {
                     $this->SetDebugData('Page Cache Info', 'Serving page from Persistent Cache: Redis (override PHP Execution). Page key is: ' . $the_page_cache_key);
                 }
                 // end if
                 return;
                 // the page was served from Cache (stop here)
             }
             //end if
         }
         //end if
         //--
     }
     //end if
     //--
     //=== if no cached, execute the code below ...
     //--
     $this->PageViewSetCfg('template-path', 'default');
     // set the template path (must be inside etc/templates/)
     $this->PageViewSetCfg('template-file', 'template.htm');
     // set the template file
     //--
     //--
     $fcontent = SmartFileSystem::staticread('lib/framework/css/ux-toolkit-samples.html');
     $arr_data = explode('<body>', $fcontent);
     $fcontent = (string) $arr_data[1];
     $arr_data = explode('</body>', $fcontent);
     $fcontent = (string) $arr_data[0];
     //--
     //-- building a semantic URL
     $url_test_unit = Smart::url_add_params($this->ControllerGetParam('url-script'), array('page' => 'samples.testunit', 'tab' => 0));
     // will generate: index.php?page=samples.testunit OR admin.php?page=samples.testunit
     $url_test_unit = Smart::url_make_semantic($url_test_unit);
     // convert the above to a pretty URL as: ?/page/samples.testunit (in this case index.php is ignored) OR admin.php?/page/samples.testunit
     //--
     //-- building a regular URL
     $url_benchmark = Smart::url_add_params($this->ControllerGetParam('url-script'), array('page' => 'samples.benchmark.html'));
     $url_benchmark = Smart::url_make_semantic($url_benchmark);
     //--
     //--
     $translator_core = SmartTextTranslations::getTranslator('@core', 'messages');
     //--
     $translator_mod_samples = SmartTextTranslations::getTranslator('mod-samples', 'samples');
     $txt_hello_world = $translator_mod_samples->text('hello-world');
     unset($translator_mod_samples);
     // this is just an internal test, normally the translator should not be unset ...
     $translator_mod_samples = SmartTextTranslations::getTranslator('mod-samples', 'samples');
     $txt_this_is_sf = $translator_mod_samples->text('this-is-smart-framework');
     //--
     //--
     $this->PageViewSetVars(['title' => 'Toolkit Samples', 'main' => '<h1>This text should not be displayed, it was RESET !!!</h1>']);
     $this->PageViewResetVar('main');
     // test reset
     $this->PageViewSetVar('main', SmartMarkersTemplating::render_template('<h1>' . '[####TXT-HELLO-WORLD####]</h1><div align="right"><b>[####DATE-TIME|html####] [[####TXT-OK####]]' . "\n" . '</b></div><br><a class="ux-button ux-button-special" href="http://sourceforge.net/projects/warp-cms/files/smart-framework/" target="_blank"><i class="fa fa-cloud-download"></i> &nbsp; Download Smart.Framework (latest stable releases)</a> &nbsp;&nbsp;&nbsp; <a class="ux-button ux-button-highlight" href="http://demo.unix-world.org/smart-framework.docs/" target="_blank"><i class="fa fa-book"></i> &nbsp; Documentation for the Smart.Framework</a><br>' . "\n" . '<br><a class="ux-button ux-button-primary" href="[####URL-TESTUNIT|html####]"><i class="fa fa-object-group"></i> &nbsp; Go to the Smart.Framework PHP/Javascript Test &amp; Demo Suite</a> &nbsp;&nbsp;&nbsp; <a class="ux-button ux-button-secondary" href="[####URL-BENCHMARK|html####]"><i class="fa fa-line-chart"></i> &nbsp; Benchmark URL for Smart.Framework</a><br><br>', ['DATE-TIME' => date('Y-m-d H:i:s O'), 'TXT-OK' => $translator_core->text('ok'), 'TXT-HELLO-WORLD' => '<span title="LanguageID: ' . Smart::escape_html($the_xlang) . '" style="cursor:help;">' . '[' . Smart::escape_html($the_lang) . ']' . '</span>' . ' ' . $txt_hello_world . ', ' . $txt_this_is_sf . ' - a modern PHP / Javascript framework featuring MVC + Middlewares', 'URL-TESTUNIT' => $url_test_unit, 'URL-BENCHMARK' => $url_benchmark]));
     $this->PageViewAppendVar('main', '<hr><div style="color:#DDDDDD">' . Smart::escape_html('Unicode@String :: Smart スマート // Cloud Application Platform クラウドアプリケーションプラットフォーム :: áâãäåāăąÁÂÃÄÅĀĂĄ ćĉčçĆĈČÇ ďĎ èéêëēĕėěęÈÉÊËĒĔĖĚĘ ĝģĜĢ ĥħĤĦ ìíîïĩīĭȉȋįÌÍÎÏĨĪĬȈȊĮ ijĵIJĴ ķĶ ĺļľłĹĻĽŁ ñńņňÑŃŅŇ óôõöōŏőøœÒÓÔÕÖŌŎŐØŒ ŕŗřŔŖŘ șşšśŝßȘŞŠŚŜ țţťȚŢŤ ùúûüũūŭůűųÙÚÛÜŨŪŬŮŰŲ ŵŴ ẏỳŷÿýẎỲŶŸÝ źżžŹŻŽ') . '</div><hr><div align="right">[' . Smart::escape_html($some_var_from_request) . ']</div>');
     $this->PageViewAppendVar('main', trim($fcontent));
     //--
     //== cache page (if redis - persistent cache is set in config)
     //-- if Redis is active this will cache the page for 1 hour ...
     if ($this->PageCacheisActive()) {
         //--
         $this->PageSetInCache('cached-samples', $the_page_cache_key, array('configs' => $this->PageViewGetCfgs(), 'vars' => $this->PageViewGetVars()), 3600);
         //--
         if ($this->IfDebug()) {
             $this->SetDebugData('Page Cache Info', 'Setting page in Persistent Cache: Redis (after PHP Execution). Page key is: ' . $the_page_cache_key);
         }
         //end if
         //--
     } else {
         //--
         if ($this->IfDebug()) {
             $this->SetDebugData('Page Cache Info', 'Persistent Cache (Redis) is not active. Serving Page from PHP Execution.');
         }
         //end if
         //--
     }
     //end if else
     //--
 }