PageRenderTime 38ms CodeModel.GetById 9ms RepoModel.GetById 1ms app.codeStats 0ms

/system/application/views/core/newlink.php

https://github.com/xupisco/Xare-a-Link
PHP | 364 lines | 315 code | 48 blank | 1 comment | 51 complexity | 8bec1e31a07b220ac90163a380e582ca MD5 | raw file
  1. <?php
  2. $_seo['is_home'] = true;
  3. $this->load->view("common/layout_top", $_seo);
  4. ?>
  5. <script src="<?= base_url(); ?>js/jquery_charcounter.js" language="JavaScript"></script>
  6. <script src="<?= base_url(); ?>js/jquery_impromptu.js" language="JavaScript"></script>
  7. <script src="<?= base_url(); ?>js/jquery_selectboxes.js" language="JavaScript"></script>
  8. <script type="text/javascript">
  9. $(document).ready(function() {
  10. $("#link_desc").charCounter(255, {
  11. container: "<span style='font-size: 11px'>",
  12. classname: "counter",
  13. format: "%1 caracteres restantes!",
  14. pulse: false
  15. });
  16. $("#ndb").click(function() {
  17. tmp = "last";
  18. $.prompt(txt,{
  19. callback: mycallbackform,
  20. show: 'fadeIn',
  21. opacity: '0.8',
  22. overlayspeed: 'fast',
  23. buttons: { Incluir: 'OK', Cancelar: 'Cancel' }
  24. });
  25. //$("#dirName").focus();
  26. });
  27. parseDest(1);
  28. });
  29. var lvl_cnt = <?= $parents_cnt ?>;
  30. var lvl = 0;
  31. var tmp = 0;
  32. var txt = "";
  33. var cvals = "";
  34. var cpath = "";
  35. var validLink = true;
  36. function removeTyped(force) {
  37. force = (!force) ? 0 : 1;
  38. if(force) {
  39. $("#new_dir").css("display","inline");
  40. } else {
  41. $("#new_dir").hide();
  42. }
  43. $("#new_dir_c").hide();
  44. $("#new_dir_txt").html("");
  45. parseDest(1);
  46. }
  47. function removeDir(n, g) {
  48. g = (!g) ? 0 : g;
  49. removed = 0;
  50. for(i = n; i <= lvl_cnt; i++) {
  51. div = "#ddir_" + i;
  52. $(div).remove();
  53. removed++;
  54. }
  55. lvl_cnt = (lvl_cnt - removed) + 1;
  56. if(g) {
  57. getDir(g, parseInt(n)-1);
  58. }
  59. removeTyped();
  60. parseDest(1);
  61. }
  62. function parseDest(w) {
  63. w = (!w) ? 0 : w;
  64. cvals = "";
  65. cpath = "";
  66. for(i=0; i< lvl_cnt; i++) {
  67. opt = "#dir_" + i + " option:selected";
  68. if($(opt).val() != "0") {
  69. cvals += $(opt).val() + "|||||";
  70. cpath += $(opt).text() + " / ";
  71. }
  72. }
  73. if($("#new_dir_txt").html().length > 2) {
  74. cvals += "new_" + $("#new_dir_txt").html() + "|||||";
  75. }
  76. cvals = cvals.substr(0, cvals.length - 5);
  77. cpath = cpath.substr(0, cpath.length - 3);
  78. ctitle = $("#link_title").val();
  79. if(w) {
  80. ct = (ctitle.length) ? " / <b style='color: #dd2222'>" + ctitle + "</b>" : "";
  81. typed = $("#new_dir_txt").html();
  82. t = (typed.length) ? " / (+) " + typed : "";
  83. $("#ldest").html(cpath + t + ct);
  84. }
  85. $("#h_parents").val(cvals);
  86. return true;
  87. }
  88. function getDir(id, lvl) {
  89. $.post("ajax/getdir/", { id: (id), lvl: (lvl)},
  90. function(data){
  91. if(data != "NONE") {
  92. $("#new_dir").hide();
  93. next = "#ddir_" + lvl;
  94. $(next).after(data);
  95. lvl_cnt++;
  96. } else {
  97. $("#new_dir").css("display","inline");
  98. }
  99. $("#loader").hide();
  100. }
  101. );
  102. }
  103. function cleanMe(e, txt) {
  104. if(e.value == txt) e.value = "";
  105. }
  106. function seedMe(e, txt) {
  107. if(e.value.length == 0) e.value = txt;
  108. }
  109. function getPR() {
  110. url = $("#link_url").val();
  111. if(url != "http://" && url != "0" && url != "") {
  112. validLink = false;
  113. $.post("ajax/getpr/", { url: (url) },
  114. function(data){
  115. $("#quick_pr").html("PageRank: " + data + " ");
  116. $("#quick_pr").show();
  117. }
  118. );
  119. $.post("ajax/validateURL/", { url: (url) },
  120. function(data){
  121. if(data == "FOUND") {
  122. validLink = false;
  123. $("#quick_pr").hide();
  124. $("#urlerror").show();
  125. } else {
  126. validLink = true;
  127. }
  128. }
  129. );
  130. $("#link_title").val("Buscando título...");
  131. $("#link_desc").val("Buscando descrição...");
  132. $.post("ajax/getmeta/", { url: (url) },
  133. function(data) {
  134. d = data.split("|||||");
  135. if(d[0] != "error") {
  136. $("#link_title").val(d[0]);
  137. $("#link_desc").focus();
  138. } else { $("#link_title").val(""); }
  139. if(d[1] != "error") {
  140. $("#link_desc").val(d[1]);
  141. $("#link_desc").blur();
  142. } else { $("#link_desc").val(""); }
  143. }
  144. );
  145. } else {
  146. $("#quick_pr").hide();
  147. }
  148. $("#urlerror").hide();
  149. }
  150. txt += "<b>Digite o nome do novo grupo!</b>";
  151. txt += '<br /><img src="images/common/dot.gif" width="1" height="10" /><br />';
  152. txt += '<input type="text" id="dirName" name="dir_name" value="Nome..." style="width: 256px; padding: 4px;" onfocus="cleanMe(this, \'Nome...\');" onblur="seedMe(this, \'Nome...\');" />';
  153. function mycallbackform(v, m){
  154. nn = m.children('#dirName').val();
  155. if(v == "OK") {
  156. if(nn != "Nome...") {
  157. if(tmp != "last") {
  158. selected = "#dir_" + tmp;
  159. ngo = "nd_" + tmp;
  160. $(selected).addOption("new_" + nn, "(+) " + nn, true);
  161. removeDir(parseInt(tmp) + 1);
  162. } else {
  163. $("#new_dir").hide();
  164. $("#new_dir_c").css("display","inline");
  165. $("#new_dir_txt").html(nn);
  166. }
  167. parseDest(1);
  168. }
  169. }
  170. }
  171. function parseDir(e) {
  172. lvl = e.id.replace("dir_", "");
  173. val = e.value.replace("nd_", "");
  174. if(e.value.substr(0,3) == "nd_") {
  175. tmp = lvl;
  176. $.prompt(txt,{
  177. callback: mycallbackform,
  178. show: 'fadeIn',
  179. opacity: '0.8',
  180. overlayspeed: 'fast',
  181. buttons: { Incluir: 'OK', Cancelar: 'Cancel' }
  182. });
  183. } else {
  184. if(val == "0") {
  185. removeDir(parseInt(lvl)+1);
  186. return false;
  187. }
  188. removeDir(parseInt(lvl)+1, val);
  189. $("#loader").css("display","inline");
  190. }
  191. }
  192. function toggleBG(i, e) {
  193. if(i) { $(e).css({ backgroundColor: '#F2FFE8' }); }
  194. else { $(e).css({ backgroundColor: '#ffffff' }); }
  195. }
  196. function parseForm() {
  197. if(!validLink) {
  198. alert("Problema com a URL. Digite novamente!!!");
  199. return false;
  200. }
  201. $("#n_parents").val(cpath);
  202. if(!$("#link_title").val()) {
  203. alert("Título do link obrigatório!");
  204. return false;
  205. }
  206. $("#urlerror").hide();
  207. return true;
  208. }
  209. </script>
  210. <style>
  211. @import "css/impromptu.css";
  212. </style>
  213. <!-- Width = 100% para pegar a largura toda. 760 = Default -->
  214. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  215. <tr>
  216. <td align="left">
  217. <img src="images/common/dot.gif" width="1" height="6" />
  218. <div>
  219. <b>Buscar por:</b> <input type="text" name="q" value="" class="main_search" /> <select name="qt" class="main_select"><option value="all">Em qualquer lugar&nbsp;&nbsp;</option></select>
  220. </div>
  221. <img src="images/common/dot.gif" width="1" height="12" /><br />
  222. <table width="100%" cellpadding="0" cellspacing="0">
  223. <tr>
  224. <td class="str_nav">
  225. <img src="images/common/dot.gif" width="2" height="1" /><a href="<?= base_url(); ?>index.html"><b>x.are</b></a>
  226. <span class="nav_sep">&raquo;</span>
  227. <a href="newlink/rel=<?= $rel; ?>" id="content_name">Novo link</a>
  228. </td>
  229. </tr>
  230. </table>
  231. </td>
  232. </tr>
  233. <tr>
  234. <td class="default_content" valign="top" align="left">
  235. <div id="content_desc" style="padding-left: 2px">Formulário para inclusão de novo link. Siga as instruções que tudo da certo.</div>
  236. <img src="images/common/dot.gif" width="1" height="8" /><br />
  237. <div id="dbar">
  238. <div style="float: left"><img src="images/icons/step_01.gif" /></div>
  239. <div style="float: right">Dúvidas? Leia nosso FAQ</div>
  240. <b>Informações básicas</b>
  241. </div>
  242. <form action="post" method="post" onsubmit="return parseForm();">
  243. <div id="content_rel">
  244. <table width="100%" cellpadding="4" cellspacing="2">
  245. <tr><td align="right" valign="top" nowrap="nowrap"><img src="images/common/dot.gif" width="1" height="3" /><br />Endereço (URL): </td><td><input type="text" class="std_input" value="http://" name="link_url" id="link_url" onblur="getPR()" /><div id="quick_pr" style="display: none; font-size: 11px; color: #777777; padding-top: 2px">PageRank: </div><div id="urlerror" style="display: none; font-size: 11px; color: #ff0000; padding-top: 2px">Essa URL já está cadastrada.</div></td><td style="font-size: 11px; color: #777777; padding-left: 10px;" valign="top"><img src="images/common/dot.gif" width="1" height="5" /><br />Não publique links repetidos, faça uma busca antes de incluir.</td></tr>
  246. <tr><td align="right" width="10%">Título do link: </td><td width="40%"><input type="text" class="std_input" name="link_title" id="link_title" onblur="parseDest(1)" /></td><td style="font-size: 11px; color: #777777; padding-left: 10px;" width="30%">Como o link será listado nas páginas.</td></tr>
  247. <tr><td align="right" valign="top"><img src="images/common/dot.gif" width="1" height="2" /><br />Descrição: </td><td><textarea class="std_ta" name="link_desc" id="link_desc"></textarea></td><td style="font-size: 11px; color: #777777; padding-left: 10px;" valign="top"><img src="images/common/dot.gif" width="1" height="2" /><br />Observe o limite de caracteres e seja o mais objetivo possível.</td></tr>
  248. </table>
  249. </div>
  250. <div id="dbar">
  251. <div style="float: left"><img src="images/icons/step_02.gif" /></div>
  252. <div style="float: right">Selecione um diretório para o link</div>
  253. <b>Segmentação</b></div>
  254. <img src="images/common/dot.gif" width="1" height="10" /><br />
  255. <div id="content_rel" style="padding: 7px;">
  256. <div id="null" style="display: inline;"><b>x.are</b></div>
  257. <div id="sep" style="display: inline;"><span class="nav_sep">&raquo;</span></div>
  258. <? for($i = 0; $i < ($parents_cnt); $i++) { $rs = "lvl_$i"?>
  259. <div id="ddir_<?= $i ?>" style="display: inline;">
  260. <div style="display: inline;">
  261. <select name="dir_<?= $i ?>" id="dir_<?= $i ?>" onchange="parseDir(this)">
  262. <option value="0">Selecione</option>
  263. <option value="0" style="color: #dddddd">---------------</option>
  264. <?php
  265. foreach($$rs as $row) {
  266. $sel = ($row->id == $parents[$i]) ? " selected" : "";
  267. echo "<option value='".$row->id."'$sel>".$row->name."</option>";
  268. }
  269. ?>
  270. <option value="0" style="color: #dddddd">---------------</option>
  271. <option value="nd_<?= $i ?>" style="color: #ee2222"> + incluir grupo</option>
  272. </select>
  273. </div>
  274. <?php if($i != 0) { ?>
  275. <div style="display: inline; vertical-align: middle" id="remove_<?= $i ?>"><a href="javascript:removeDir(<?= $i ?>);"><img src="images/icons/dir_remove.gif" border="0" title="Remover este sub-grupo" /></a></div>
  276. <?php } ?>
  277. <?php if($i != ($parents_cnt - 1)) { ?>
  278. <div id="sep" style="display: inline;"><span class="nav_sep">&raquo;</span></div>
  279. <?php } ?>
  280. </div>
  281. <? } ?>
  282. <div style="display: none;" id="loader">
  283. <div style="display: inline; vertical-align: middle;" id="loader_img"><img src="images/ajax_loader-content.gif" /></div>
  284. <div id="sep" style="display: inline;"><span class="nav_sep">&raquo;</span></div>
  285. </div>
  286. <div id="new_dir" style="display: <?= ($showb == 0) ? "inline" : "none"; ?>">
  287. <input type="button" value=" + Sub-grupo " id="ndb" / ></div>
  288. <div id="new_dir_c" style="display: none;">
  289. <div id="new_dir_txt" style="display: inline; font-weight: bold"></div>
  290. <div style="display: inline; vertical-align: middle" id="remove_ndt"><a href="javascript:removeTyped(1);"><img src="images/icons/dir_remove.gif" border="0" title="Remover este sub-grupo" /></a></div>
  291. </div>
  292. </div>
  293. <img src="images/common/dot.gif" width="1" height="10" /><br />
  294. <div id="dbar">
  295. <div style="float: left"><img src="images/icons/step_03.gif" /></div>
  296. <div style="float: right">Confirme os dados antes de enviar</div>
  297. <b>Confirmação</b></div>
  298. <img src="images/common/dot.gif" width="1" height="4" /><br />
  299. <div style="padding: 6px; float: right">
  300. <input type="submit" value="Enviar link" style="background-color: #99C145; border: 1px solid #69832F; padding: 6px; color: #ffffff; font-weight: bold" />
  301. </div>
  302. <div style="padding: 10px; font-size: 18px">
  303. <span style="color: #888888">Destino do link:</span> <b>x.are</b> / <span id="ldest"></span>
  304. </div>
  305. <img src="images/common/dot.gif" width="1" height="10" /><br />
  306. <input type="hidden" name="h_parents" id="h_parents" value="" />
  307. <input type="hidden" name="n_parents" id="n_parents" value="" />
  308. </form>
  309. <img src="images/common/dot.gif" width="1" height="12" /><br />
  310. <div id="roots">
  311. <b>x.are</b> 2007 - Todos os direitos reservados. Leia nosso FAQ para mais informações sobre como utilizar a ferramenta.
  312. </div>
  313. </td>
  314. </tr>
  315. </table>
  316. <?php $this->load->view("common/layout_bottom"); ?>