當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CMS_Asset::add_string_js方法代碼示例

本文整理匯總了PHP中CMS_Asset::add_string_js方法的典型用法代碼示例。如果您正苦於以下問題:PHP CMS_Asset::add_string_js方法的具體用法?PHP CMS_Asset::add_string_js怎麽用?PHP CMS_Asset::add_string_js使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CMS_Asset的用法示例。


在下文中一共展示了CMS_Asset::add_string_js方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: cms_widgets

 /**
  * @author  goFrendiAsgard
  * @param  parent_id, max_menu_depth
  * @desc  return navigation child if parent_id specified, else it will return root navigation
  */
 public final function cms_widgets()
 {
     $user_name = $this->cms_username();
     $user_id = $this->cms_userid();
     $not_login = !$user_name ? "TRUE" : "FALSE";
     $login = $user_name ? "TRUE" : "FALSE";
     $super_user = $user_id == 1 ? "TRUE" : "FALSE";
     $query = $this->db->query("SELECT \n        \t\t\twidget_id, widget_name, is_static, title, \n        \t\t\tdescription, url, slug, static_content \n                FROM cms_widget AS w WHERE\n                    (                        \n                        (authorization_id = 1) OR\n                        (authorization_id = 2 AND {$not_login}) OR\n                        (authorization_id = 3 AND {$login}) OR\n                        (\n                            (authorization_id = 4 AND {$login}) AND \n                            (\n                                (SELECT COUNT(*) FROM cms_group_user AS gu WHERE gu.group_id=1 AND gu.user_id ='" . addslashes($user_id) . "')>0\n                                    OR {$super_user} OR\n                                (SELECT COUNT(*) FROM cms_group_widget AS gw\n                                    WHERE \n                                        gw.widget_id=w.widget_id AND\n                                        gw.group_id IN \n                                            (SELECT group_id FROM cms_group_user WHERE user_id = '" . addslashes($user_id) . "')\n                                )>0\n                            )\n                        )\n                    ) AND active=1");
     $result = array();
     foreach ($query->result() as $row) {
         // generate widget content
         $content = '';
         if ($row->is_static == 1) {
             $content = $this->cms_parse_keyword($row->static_content);
         } else {
             // url
             $url = $row->url;
             if (!strpos(strtolower($url), 'http')) {
                 $url = base_url($url);
             }
             // script
             $script = '$.ajax({';
             $script .= 'url:"' . $url . '",';
             $script .= 'data:{_only_content:true},';
             $script .= 'success:function(response){';
             $script .= '$("div#_cms_widget_' . $row->widget_id . '").html(response);';
             $script .= '}';
             $script .= '});';
             // asset
             $asset = new CMS_Asset();
             $asset->add_cms_js('nocms/js/jquery.js');
             $asset->add_string_js($script);
             // content
             $content .= '<div id="_cms_widget_' . $row->widget_id . '">';
             $content .= $asset->compile_js(true);
             $content .= '</div>';
         }
         // make widget based on slug
         if (!isset($result[$row->slug])) {
             $result[$row->slug] = array();
         }
         $result[$row->slug][] = array("widget_id" => $row->widget_id, "widget_name" => $row->widget_name, "title" => $this->cms_lang($row->title), "description" => $row->description, "content" => $content);
     }
     return $result;
 }
開發者ID:rado-tsvetkov,項目名稱:No-CMS,代碼行數:50,代碼來源:cms_model.php


注:本文中的CMS_Asset::add_string_js方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。