本文整理汇总了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;
}