/** * Add favicon of different messaging systems or * social sites, contained in the input data. * @param array $data with details of the social profile. * $data[]->note - the type of social profile (i.e. icq, aim, etc). * $data[]->title - display name of the social profile. * $data[]->icon - the URL of the icon. Will be populated by this function. * @return array of icon details for the specified social profile. * $newdata[]->note - originally passed into function. * $newdata[]->title - originally passed into function. * $newdata[]->icon - the URL of the icon. * $newdata[]->link - URL or application call. */ public static function get_profile_icons($data) { $newdata = array(); foreach ($data as $record) { $record->link = self::get_profile_link($record->title, $record->note); switch ($record->note) { case 'facebook': $record->icon = favicon_display_url('facebook.com'); break; case 'tumblr': $record->icon = favicon_display_url('tumblr.com'); break; case 'twitter': $record->icon = favicon_display_url('twitter.com'); break; case 'instagram': $record->icon = favicon_display_url('instagram.com'); break; case 'pinterest': $record->icon = favicon_display_url('www.pinterest.com'); break; case 'icq': $record->icon = favicon_display_url('www.icq.com'); break; case 'aim': $record->icon = favicon_display_url('www.aim.com'); break; case 'yahoo': $record->icon = favicon_display_url('messenger.yahoo.com'); break; case 'skype': // Since www.skype.com favicon is not working... $record->icon = favicon_display_url('support.skype.com'); break; case 'jabber': // Since www.jabber.org favicon is not working... $record->icon = favicon_display_url('planet.jabber.org'); break; default: // We'll fall back to the "no favicon" default icon $record->icon = favicon_display_url('example.com'); // If they've supplied a URL, use its favicon if (filter_var($record->title, FILTER_VALIDATE_URL)) { $url = parse_url($record->title); // Check if $url['host'] actually exists - just in case // it was badly formatted. if (isset($url['host'])) { $record->icon = favicon_display_url($url['host']); } } } $newdata[] = $record; } return $newdata; }
define('MENUITEM', 'configextensions/iframesites'); define('SECTION_PLUGINTYPE', 'core'); define('SECTION_PLUGINNAME', 'admin'); define('SECTION_PAGE', 'iframesites'); require dirname(dirname(dirname(__FILE__))) . '/init.php'; require_once 'pieforms/pieform.php'; require_once 'upgrade.php'; define('TITLE', get_string('allowediframesites', 'admin')); $iframesources = get_records_menu('iframe_source', '', '', 'name,prefix'); $iframedomains = get_records_menu('iframe_source_icon'); $newform = pieform(array('name' => 'newurl', 'elements' => array('url' => array('type' => 'text', 'title' => get_string('Site'), 'description' => get_string('iframeurldescription', 'admin'), 'rules' => array('minlength' => 4, 'maxlength' => 255, 'regex' => '/^[a-zA-Z0-9\\/\\._-]+$/')), 'name' => array('type' => 'text', 'title' => get_string('displayname'), 'description' => get_string('iframedisplaynamedescription', 'admin'), 'rules' => array('minlength' => 1, 'maxlength' => 100)), 'submit' => array('type' => 'submit', 'class' => 'btn-success', 'value' => get_string('add'))))); $editurls = array(); $i = 0; foreach ($iframesources as $url => $name) { $elements = array('url' => array('type' => 'hidden', 'value' => $url), 'name' => array('type' => 'text', 'title' => get_string('displayname'), 'description' => get_string('iframedisplaynamedescription', 'admin'), 'defaultvalue' => $name), 'icon' => array('type' => 'text', 'title' => get_string('iframeiconhost', 'admin'), 'description' => get_string('iframeiconhostdescription', 'admin'), 'defaultvalue' => $iframedomains[$name], 'rules' => array('minlength' => 4, 'maxlength' => 253, 'regex' => '/^[a-zA-Z0-9-]{1,63}(\\.[a-zA-Z0-9-]{1,63})+$/')), 'submit' => array('type' => 'submit', 'class' => 'btn-primary btn-sm', 'value' => get_string('save'))); $editurls[$i] = array('id' => $i, 'url' => $url, 'name' => $name, 'icon' => favicon_display_url($iframedomains[$name]), 'editform' => pieform(array('name' => 'editurl_' . $i, 'successcallback' => 'editurl_submit', 'elements' => $elements)), 'deleteform' => pieform(array('name' => 'deleteurl_' . $i, 'successcallback' => 'deleteurl_submit', 'renderer' => 'div', 'class' => 'form-inline form-as-button pull-left last', 'elements' => array('submit' => array('type' => 'button', 'class' => 'btn-default btn-sm', 'usebuttontag' => true, 'value' => '<span class="icon icon-trash icon-lg text-danger"></span><span class="sr-only">' . get_string('delete') . '</span>', 'confirm' => get_string('confirmdeletemenuitem', 'admin')), 'url' => array('type' => 'hidden', 'value' => $url))))); $i++; } function editurl_submit(Pieform $form, $values) { global $iframesources, $iframedomains, $SESSION; if (isset($iframesources[$values['url']])) { $oldname = $iframesources[$values['url']]; $newname = strip_tags($values['name']); $iframesources[$values['url']] = $newname; db_begin(); // Update the icon list if necessary if (!isset($iframedomains[$newname])) { insert_record('iframe_source_icon', (object) array('name' => $newname, 'domain' => $values['icon'])); } else { if ($iframedomains[$newname] != $values['icon']) {
/** * Returns a block of HTML that the external video block can use to show the * sites for which iframes are allowed. */ private static function get_valid_iframe_html() { $iframedomains = get_records_menu('iframe_source_icon', '', '', 'name'); if (empty($iframedomains)) { return ''; } $data = array(); foreach ($iframedomains as $name => $host) { $data[$name] = array('name' => $name, 'url' => 'http://' . $host, 'icon' => favicon_display_url($host)); } $smarty = smarty_core(); $smarty->assign('data', $data); return $smarty->fetch('blocktype:externalvideo:sitelist.tpl'); }
define('MENUITEM', 'configextensions/iframesites'); define('SECTION_PLUGINTYPE', 'core'); define('SECTION_PLUGINNAME', 'admin'); define('SECTION_PAGE', 'iframesites'); require dirname(dirname(dirname(__FILE__))) . '/init.php'; require_once 'pieforms/pieform.php'; require_once 'upgrade.php'; define('TITLE', get_string('allowediframesites', 'admin')); $iframesources = get_records_menu('iframe_source', '', '', 'name,prefix'); $iframedomains = get_records_menu('iframe_source_icon'); $newform = pieform(array('name' => 'newurl', 'elements' => array('url' => array('type' => 'text', 'title' => get_string('Site'), 'description' => get_string('iframeurldescription', 'admin'), 'rules' => array('minlength' => 4, 'maxlength' => 255, 'regex' => '/^[a-zA-Z0-9\\/\\._-]+$/')), 'name' => array('type' => 'text', 'title' => get_string('displayname'), 'description' => get_string('iframedisplaynamedescription', 'admin'), 'rules' => array('minlength' => 1, 'maxlength' => 100)), 'submit' => array('type' => 'submit', 'value' => get_string('add'))))); $editurls = array(); $i = 0; foreach ($iframesources as $url => $name) { $elements = array('url' => array('type' => 'hidden', 'value' => $url), 'name' => array('type' => 'text', 'title' => get_string('displayname'), 'description' => get_string('iframedisplaynamedescription', 'admin'), 'defaultvalue' => $name), 'icon' => array('type' => 'text', 'title' => get_string('iframeiconhost', 'admin'), 'description' => get_string('iframeiconhostdescription', 'admin'), 'defaultvalue' => $iframedomains[$name], 'rules' => array('minlength' => 4, 'maxlength' => 253, 'regex' => '/^[a-zA-Z0-9-]{1,63}(\\.[a-zA-Z0-9-]{1,63})+$/')), 'submit' => array('type' => 'submit', 'value' => get_string('save'))); $editurls[$i] = array('id' => $i, 'url' => $url, 'name' => $name, 'icon' => favicon_display_url($iframedomains[$name]), 'editform' => pieform(array('name' => 'editurl_' . $i, 'successcallback' => 'editurl_submit', 'elements' => $elements)), 'deleteform' => pieform(array('name' => 'deleteurl_' . $i, 'successcallback' => 'deleteurl_submit', 'renderer' => 'oneline', 'class' => 'oneline inline', 'elements' => array('url' => array('type' => 'hidden', 'value' => $url), 'submit' => array('type' => 'image', 'src' => $THEME->get_url('images/btn_deleteremove.png'), 'alt' => get_string('deletespecific', 'mahara', $name), 'elementtitle' => get_string('delete'), 'confirm' => get_string('confirmdeletemenuitem', 'admin')))))); $i++; } function editurl_submit(Pieform $form, $values) { global $iframesources, $iframedomains, $SESSION; if (isset($iframesources[$values['url']])) { $oldname = $iframesources[$values['url']]; $newname = strip_tags($values['name']); $iframesources[$values['url']] = $newname; db_begin(); // Update the icon list if necessary if (!isset($iframedomains[$newname])) { insert_record('iframe_source_icon', (object) array('name' => $newname, 'domain' => $values['icon'])); } else { if ($iframedomains[$newname] != $values['icon']) {