当前位置: 首页>>代码示例>>PHP>>正文


PHP functions::truncateStringByWord方法代码示例

本文整理汇总了PHP中functions::truncateStringByWord方法的典型用法代码示例。如果您正苦于以下问题:PHP functions::truncateStringByWord方法的具体用法?PHP functions::truncateStringByWord怎么用?PHP functions::truncateStringByWord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在functions的用法示例。


在下文中一共展示了functions::truncateStringByWord方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendAnnouncementForm

 private static function sendAnnouncementForm($founderror = array(), $dbData = array())
 {
     $stdout = "";
     if (!$GLOBALS["send"] && !$GLOBALS["template_id"]) {
         return "<div class='col-content-1of3'>\r\n" . "  <h3><span class='green anfang'>1</span> Make sure the new newsletter " . "<span class='nowrap'>is ready</span> for publication</h3>\r\n" . "  <p>The issue to be released is ....</p>\r\n" . "  <p>[Not ready yet...]</p>\r\n" . "</div> <div class='col-content-2of3 divider'>\r\n" . "  <h3><span class='green anfang'>2</span> Check that the " . "list of e-mail subscriptions " . "<span class='nowrap'>is up to date</span></h3>\r\n" . "  <p style='margin-bottom:-1em'>There are currently</p>\r\n" . "  <p class='nowrap bold green' style='font-size:1.3em; " . "margin-bottom:-0.5em;text-indent:1em'>" . $GLOBALS["newsClass"]->getNumberOfSubscribers() . " active subscribers.</p>\r\n" . "  <p>You can <a href='" . SUBSITE . "/subscriptions/announcement_edit/index.php'><strong>view and " . "edit the list of subscribers</strong></a>. " . "Only subscriptions marked 'active' will receive " . "an announcement by e-mail.</p>\r\n" . "</div> <div class='col-content-3of3 divider'>\r\n" . "  <h3 class='bottommargin'><span class='green anfang'>3</span> Edit and<br>send the announcement e-mail</h3>\r\n" . "<form method='post' action='" . $_SERVER["PHP_SELF"] . "' style='margin-bottom:2em;text-align:right'>\r\n" . "  <input type='submit' value='Continue to the e-mail form &#187;' class='fakelink h4'>\r\n" . "  <input type='hidden' name='template_id' value='1'>\r\n" . "</form>\r\n" . "</div><div style='clear:both'><br></div>\r\n" . "\r\n";
     }
     //debug::rrr();
     //debug::rr($dbData);
     $stdout .= "<div class='col-content-left1third'>\r\n";
     if (empty($dbData)) {
         $stdout .= "<p class='messages error bold'>There are no announcement templates. " . "Please write your own text in the form below.</p>\r\n";
     } else {
         $news_url = isInPath("/" . PATH_NEWSEDITTEST . "/") ? PATH_NEWSEDITTEST : PATH_NEWSEDIT;
         $stdout .= "<h3 class='bottommargin'>First select a " . "<a href='" . $news_url . "/subscriptions/announcement_template/index.php'>template</a>:</h3>\r\n";
         foreach ($dbData as $id => $data) {
             $stdout .= "<form method='post' action='" . $_SERVER["PHP_SELF"] . "'>\r\n" . "  <input type='submit' value='" . $data["title"] . "' " . "class='fakelink' style='font-size:1.2em;font-weight:bold'>\r\n" . (isset($data["isdefault"]) && $data["isdefault"] ? " <span style='color:black;font-weight:normal;font-style:italic;padding-left:0.5em'>[default]</span>" : "") . "  <input type='hidden' name='template_id' value='" . ($id + 1) . "'>\r\n" . "  <p" . " style='margin-left:2em;margin-top:0;font-style:italic;line-height:1.0;font-size:0.9em'" . ">&quot;" . functions::truncateStringByWord($data["text"], 120) . "...&quot;</p>\r\n" . "</form>\r\n";
         }
     }
     $stdout .= "</div> <div class='col right2of3'>\r\n";
     $stdout .= "<h3 class='bottommargin'>Then edit the message and send:</h3>\r\n";
     foreach ($founderror as $error) {
         $stdout .= "<p class='messages error bold'>&#187; " . $error . "</p>\r\n";
     }
     $stdout .= "<form method='post' action='" . $_SERVER["PHP_SELF"] . "' style='margin-bottom:2em'>\r\n" . "  <table class='padding'>\r\n" . "    <tr>\r\n" . "      <td style='text-align:right;padding:0'><span class='red'>*</span></td>\r\n" . "      <td>Subject line:</td>\r\n" . "    </tr>\r\n" . "    <tr>\r\n" . "      <td></td>\r\n" . "      <td><input" . (isset($founderror["subject"]) ? " class='error'" : "") . "  type='text' name='subject' size='60' value='" . (!empty($GLOBALS["subject"]) ? $GLOBALS["subject"] : "") . "'></td>\r\n" . "    </tr>\r\n" . "    <tr>\r\n" . "      <td style='text-align:right;padding:0'><span class='red'>*</span></td>\r\n" . "      <td>Message:\r\n" . "      </td>\r\n" . "    </tr>\r\n" . "    <tr>\r\n" . "      <td></td>\r\n" . "      <td><textarea" . (isset($founderror["text"]) ? " class='error'" : "") . " name='text' rows='20' cols='55'>" . (!empty($GLOBALS["text"]) ? $GLOBALS["text"] : (isset($dbData[$GLOBALS["template_id"] - 1]) ? $dbData[$GLOBALS["template_id"] - 1]["text"] : "")) . "</textarea></td>\r\n" . "    </tr>\r\n" . "    <tr>\r\n" . "      <td colspan='3' style='text-align:right;padding-top:0.5em'>\r\n" . "        <input type='submit' value='Send Announcement Mail'>\r\n" . "        <input type='input' name='" . HONEYTRAP_ID . "' class='osynl'>\r\n" . "        <input type='hidden' name='send' value='1'>\r\n" . "      </td>\r\n" . "    </tr>\r\n" . "  </table>\r\n" . "</form>\r\n";
     if (NEWS_DEBUG) {
         $to = ($username = auth::getUsername()) && functions::isEmailAddress($username . "@nordita.org") ? $username . "@nordita.org" : "hvzm@nordita.org";
         $stdout .= "<h1 class='red'>TEST MODE!</h1>\r\n" . "<p class='red h4'>Actually only '<strong>" . $to . "</strong>' will get this mail</p>\r\n";
         //"<p>Only seleted beta testers actually get these mails</p>\r\n";
     }
     $stdout .= "</div><div style='clear:both'><br></div>\r\n";
     return $stdout;
 }
开发者ID:,项目名称:,代码行数:32,代码来源:

示例2: outputPositionsDropdown

 public static function outputPositionsDropdown($text = "data", $id = "position_id", $maxChars = 35)
 {
     $stdout = "";
     $data = array();
     functions::gpc_declare_input($id, "", false);
     // -----------------------------
     // -- Obtain data
     // -----------------------------
     $campaigns = functions::callMethod('fromdb_nwpositions', 'fromdb/nwpositions', 'getCampaigns');
     if (empty($campaigns)) {
         return "";
     }
     foreach ($campaigns as $regend => $arr) {
         foreach ($arr as $idx => $a) {
             $data[$regend . " " . $idx] = array($id => $a[$id], "title" => isset($a["title"]) ? $a["title"] : "", "regend" => isset($a["regend"]) ? $a["regend"] : "");
         }
     }
     krsort($data);
     // -----------------------------
     // -- Dropdown list
     // -----------------------------
     $dropdownList = "            <strong>Select the Nordita position</strong> for which you want to display the " . $text . ":\r\n" . "            <br><select name='" . $id . "' onchange='submit()' style='font-size:1.1em'>\r\n" . "              <option value='0'>-&#45;- select from list -&#45;-</option>\r\n";
     foreach ($data as $pos) {
         $lbl = functions::truncateStringByWord($pos["title"], $maxChars);
         $lbl = substr($pos["title"], 0, $maxChars);
         if ($maxChars < strlen($pos["title"])) {
             $lbl .= "...";
         }
         $dropdownList .= "              <option value='" . $pos["position_id"] . "'" . (isset($_REQUEST[$id]) && $pos[$id] == $_REQUEST[$id] ? " selected" : "") . (strtotime($pos["regend"]) >= time() ? " class='future'>" . $pos["regend"] . " &nbsp; " . $lbl : " class='past'>" . $pos["regend"] . " &nbsp; [" . $lbl . "]") . "</option>\r\n";
     }
     // end foreach
     $dropdownList .= "            </select>\r\n" . "\r\n";
     // -----------------------------
     $stdout .= "        <div class='only_online'>\r\n" . "          <form " . "action='" . $_SERVER["PHP_SELF"] . "' " . "method='POST' " . "enctype='multipart/form-data' " . "name='ST1'>\r\n" . $dropdownList . "          </form>\r\n" . "        </div>\r\n" . "\r\n";
     return $stdout;
 }
开发者ID:,项目名称:,代码行数:36,代码来源:

示例3: outputFeed

 public static function outputFeed($feedchannel = array(), $feeditems = array(), $inArchive = false)
 {
     $stdout = "";
     // ---------------------------------
     $channelUrlXml = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"];
     $channelUrlHtml = str_replace("/feed", "", $channelUrlXml);
     //if ($inArchive)
     $channelUrlHtml = str_replace("/index.php", "", $channelUrlHtml) . "/archive/index.php";
     // ---------------------------------
     $preamble = "<" . "?xml version='1.0' encoding='UTF-8'?" . ">\r\n" . "\r\n";
     // ---------------------------------
     //TODO
     $stylesheet = empty($feedchannel["stylesheetFile"]) ? "" : "<" . "?xml-stylesheet type='text/xsl' media='screen' href='" . $feedchannel["stylesheetFile"] . "'?" . ">\r\n" . "\r\n";
     // ---------------------------------
     $root = "<rss version='2.0'\r\n" . "     xmlns:admin='http://webns.net/mvcb/'\r\n" . "     xmlns:atom='http://www.w3.org/2005/Atom'\r\n" . "     xmlns:cc='http://web.resource.org/cc/'\r\n" . "     xmlns:content='http://purl.org/rss/1.0/modules/content/'\r\n" . "     xmlns:creativeCommons='http://backend.userland.com/creativeCommonsRssModule'\r\n" . "     xmlns:dc='http://purl.org/dc/elements/1.1/'\r\n" . "     xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'\r\n" . "     xmlns:slash='http://purl.org/rss/1.0/modules/slash/'\r\n" . "     xmlns:sy='http://purl.org/rss/1.0/modules/syndication/'\r\n" . ">\r\n" . "\r\n";
     // ---------------------------------
     $channelHeader = "  <channel>\r\n" . "    <title>" . $feedchannel["channelTitle"] . "</title>\r\n" . "    <link>" . $channelUrlHtml . "</link>\r\n" . "    <description>" . $feedchannel["channelDescription"] . "</description>\r\n" . "    <atom:link href='" . $channelUrlXml . "' rel='self' type='application/rss+xml' />\r\n" . "    <language>en-US</language>\r\n" . "    <managingEditor>info@nordita.org (Hans Mühlen)</managingEditor>\r\n" . "    <webMaster>info@nordita.org (Hans Mühlen)</webMaster>\r\n" . "    <admin:errorReportsTo rdf:resource='mailto:info@nordita.org' />\r\n" . "    <copyright>Copyright 2007-" . date("Y") . ", Nordita</copyright>\r\n" . "    <category>Newsletter</category>\r\n" . "    <image>\r\n" . "      <url>" . URL_PREFIX . "/img/_theme/th-frost/icon_apple.png</url>\r\n" . "      <link>" . $channelUrlHtml . "</link>\r\n" . "      <title>The Nordita Newsletter</title>\r\n" . "      <description>" . $feedchannel["channelTitle"] . "</description>\r\n" . "      <width>57</width>\r\n" . "      <height>57</height>\r\n" . "    </image>\r\n" . "    <ttl>1440</ttl>\r\n" . "    <sy:updatePeriod>daily</sy:updatePeriod>\r\n" . "    <sy:updateFrequency>1</sy:updateFrequency>\r\n" . "    <sy:updateBase>2007-01-01T12:00+00:00</sy:updateBase>\r\n" . "\r\n";
     // ---------------------------------
     $channelFooter = "  </channel>\r\n" . "\r\n" . "</rss>\r\n" . "\r\n";
     // ---------------------------------
     $itemlist = "";
     //foreach ($feeditems as $date => $items) {
     //  foreach ($items as $key => $item) {
     foreach ($feeditems as $key => $item) {
         $itemId = $key;
         $item["text"] = trim(preg_replace("/[\r\n]/", " ", $item["text"]));
         $item["title"] = trim(str_replace("&nbsp;", " ", strip_tags($item["title"])));
         $itemlist .= "    <item>\r\n" . "      <title>" . $item["title"] . "</title>\r\n" . "      <link>" . $channelUrlHtml . "#" . $itemId . "</link>\r\n" . "      <source url='" . $channelUrlXml . "'>" . $item["title"] . "</source>\r\n" . "";
         foreach ($item["cat"] as $cat) {
             // -- CATEGORIES OF ITEM
             $itemlist .= "      <category><![CDATA[" . $cat . "]]></category>\r\n";
         }
         $itemlist .= "      <guid isPermaLink='false'>" . $channelUrlHtml . "#" . $itemId . "</guid>\r\n" . "      <description><![CDATA[" . functions::truncateStringByWord(strip_tags($item["text"]), 200) . " [...]]]></description>\r\n" . "      <content:encoded><![CDATA[" . str_replace("src='img/", "src='" . URL_PREFIX . "/img/", $item["text"]) . "]]></content:encoded>\r\n" . "    </item>\r\n" . "\r\n";
         //      } // end foreach
     }
     // end foreach
     // ---------------------------------
     return $preamble . $stylesheet . $root . $channelHeader . $itemlist . $channelFooter;
 }
开发者ID:,项目名称:,代码行数:39,代码来源:

示例4: AnewseditCreateTestDb

 public static function AnewseditCreateTestDb($select = "")
 {
     $stdout = "";
     functions::gpc_declare_input("doit", false, true);
     if ($GLOBALS["doit"]) {
         $stdout .= "<div class='box blackborder padding' style='max-width:752px'>\r\n" . "  <form action='" . $_SERVER["PHP_SELF"] . "' method='post'>\r\n" . "    <input type='submit' name='doit' value='Drop and recreate " . ($select == "test" ? "TEST " : "REAL ") . "database again'>\r\n" . "  </form>\r\n" . "</div>\r\n\r\n";
         //      if (!class_exists("fromdb_client",FALSE)) require_once PATH_CLASSES . "/fromdb/client.php";
         //      $dbClient = new fromdb_client();
         // Includes connect to "nordita" database
         // Also gives access to the following useful functions:
         //   function client_connectToDatabase ($db_host,$db_user,$db_password,$db_database)
         //   function client_submitQuery ($nr,$ledtext,$sqlStmt,$showsql)
         //   function client_safeMysqlQuery ($sqlStmt,$queryName)
         //   function client_safeMysqlFetchRow ($resultset)
         //   function client_safeMysqlFetchAssoc ($resultset)
         if (!class_exists("fromdb_nwnews", FALSE)) {
             require_once PATH_CLASSES . "/fromdb/nwnews.php";
         }
         $dbClient = new fromdb_nwnews();
         // includes connect to "nordita" database
         unset($SQL);
         // Define array $SQL[] in these insert files:
         switch ($select) {
             case "empty":
                 $news_db_prefix = "norditanews_";
                 require PATH_SQL . "/sql_news_create_tables.php";
                 break;
             case "lookup":
                 $news_db_prefix = "norditanews_";
                 require PATH_SQL . "/sql_news_insertlookup.php";
                 break;
             case "article":
                 $news_db_prefix = "norditanews_";
                 require PATH_SQL . "/sql_news_insertarticle.php";
                 break;
             case "subscribe":
                 $news_db_prefix = "norditanews_";
                 require PATH_SQL . "/sql_news_insertsubscribe.php";
                 break;
             case "test":
                 $news_db_prefix = "norditanewstest_";
                 require PATH_SQL . "/sql_news_create_tables.php";
                 require PATH_SQL . "/sql_news_insertlookup.php";
                 require PATH_SQL . "/sql_news_inserttest.php";
                 break;
         }
         if (is_array($SQL)) {
             $stdout .= "<ol class='tightlist'>\r\n";
             foreach ($SQL as $sqlStmt) {
                 $stdout .= $dbClient->query($sqlStmt) ? "  <li><strong class='green'>OK</strong> - " . functions::truncateStringByWord($sqlStmt) . "</li>\r\n" : "  <li><strong class='red'>ERROR</strong> - " . functions::truncateStringByWord($sqlStmt) . "<br>" . $dbClient->dbMysqlError . "</li>\r\n";
             }
             $stdout .= "</ol>\r\n";
             $stdout .= "<h3 class='green'>Done</h3>";
         } else {
             $stdout .= "<h3 class='red'>Found no SQL statements to execute</h3>";
         }
     } else {
         $stdout .= "<h3 class='red bottommargin'>WARNING</h3>\r\n" . "\r\n" . "<form action='" . $_SERVER["PHP_SELF"] . "' method='post'>\r\n" . "  <input type='submit' name='doit' value='Drop and Recreate Database with " . (isInPath("_test/") ? "TEST " : "REAL ") . "Data'>\r\n" . "</form>\r\n" . "\r\n";
     }
     return $stdout;
 }
开发者ID:,项目名称:,代码行数:61,代码来源:

示例5: outputMockagendaEditorList

 public static function outputMockagendaEditorList($onlyEditCurrentAndFuture = FALSE, $updatedConfId = 0, $showCacheUpdateLink = FALSE)
 {
     $stdout = "";
     // Experimental: jQuery accordion
     $stdalt = "";
     $allevents = $unallocatedevents = array();
     // --------------------------------
     // -- Obtain data
     // --------------------------------
     $allConfids = functions::callMethod('fromdb_nwevents', 'fromdb/nwevents', 'getAgendaConferenceIdsForNorditaEvents', '', '1');
     if (!is_array($allConfids) || empty($allConfids)) {
         return BLURB_SORRY_NO_EVENTS;
     }
     //TODO: use exception instead
     foreach ($allConfids as $confId) {
         $event = functions::callMethod('fromdb_nwevents', 'fromdb/nwevents', 'getOneEvent', $confId, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
         if (!empty($event)) {
             if (!empty($event["from"]) && substr($event["startdate"], -5) != "01-01") {
                 $idx = $event["from"];
                 while (isset($allevents[$idx])) {
                     $idx++;
                 }
                 $allevents[$idx] = $event;
             } elseif (!empty($event["id"])) {
                 $event["from"] = 0;
                 $unallocatedevents[$event["id"]] = $event;
             }
         }
     }
     // end foreach
     krsort($allevents);
     krsort($unallocatedevents);
     $allevents = array_merge($unallocatedevents, $allevents);
     // --------------------------------
     // -- Output data
     // --------------------------------
     $stdout .= "  <p class='largefont'><strong>Select Event to be " . ($onlyEditCurrentAndFuture ? "Updated" : "Edited") . " Below</strong>" . ($showCacheUpdateLink ? " &nbsp; or &nbsp; <strong><a href='" . $_SERVER["PHP_SELF"] . "?menulookup=1'>Recreate 'menulookup' cache</a></strong>" : "") . "</p>\r\n";
     if (!$onlyEditCurrentAndFuture) {
         $stdout .= "  <p style='margin-bottom:2em'>" . "<strong>[Edit]</strong> = edit manually kept fields in nw_events DB;" . "<br><strong>[Update]</strong> = update Agenda fields in nw_events DB from Agenda DB;" . "<br><strong>[Delete]</strong> = delete record from nw_events DB</p>\r\n";
     }
     $stdout .= "<table style='border-top:2px solid black;border-bottom:2px solid black'>\r\n";
     // Experimental: jQuery accordion
     $stdalt = "<style type='text/css'>.eventsynclist\n{\n  display: block;\n  position: relative;\n  overflow: visible;\n  clip:     inherit ! important;\n  visibility: visible;\n  float: none;\n  clear: both;\n  top:    0;\n  right:  auto;\n  bottom: auto;\n  left:   0;\n  width:  auto;\n  height: auto;\n  z-index: 25;\n}</style>\r\n" . "<div class='eventsynclist'>\r\n" . "  <h3>[Not assigned]</h3>\r\n" . "  <div><table>\r\n";
     $numberOfColumns = $onlyEditCurrentAndFuture ? 6 : 8;
     $processedYear = "";
     foreach ($allevents as $thisevent) {
         if ($thisevent["from"]) {
             $year = date("Y", $thisevent["from"]);
             // Write a year headline?
             if ((!$onlyEditCurrentAndFuture || $year >= date("Y")) && $year != $processedYear) {
                 $processedYear = $year;
                 $stdout .= "  <tr class='theyear'>\r\n" . "    <th colspan='" . $numberOfColumns . "' " . "style='border:1px solid black;padding:0.2em 1em;background-color:#eee'>" . $processedYear . "</th>\r\n" . "  </tr>\r\n";
                 // Experimental: jQuery accordion
                 $stdalt .= "  </table></div>\r\n" . "  <h3>" . $processedYear . "</h3>\r\n" . "  <div><table>\r\n";
             }
             $period = functions::readableDateInterval($thisevent["start"], $thisevent["end"], TRUE);
         } else {
             $period = "(<em>Dates missing</em>)";
         }
         // end if
         $title = functions::truncateStringByWord($thisevent["title"], 50);
         if ($thisevent["title"] != $title) {
             $title .= "...";
         }
         $img = !empty($thisevent["subpath"]) && file_exists(INCLEVEL . PATH_EVENTLOGOS . "/" . $thisevent["subpath"] . ".png") ? "<img src='" . PATH_EVENTLOGOS . "/" . $thisevent["subpath"] . ".png' alt='' style='width:10px;height:10px;border:1px solid black'>" : "";
         if (!$onlyEditCurrentAndFuture || isset($thisevent["current"]) && in_array($thisevent["current"], array("current", "future"))) {
             $stdout .= "  <tr" . ($updatedConfId == $thisevent["id"] ? " class='green'" : "") . ">\r\n" . "    <td style='padding-right:0.5em'>" . $img . "</td>\r\n" . "    <td style='padding-right:0.5em' class='bold' title='" . $thisevent["subpath"] . "'>" . $title . "</td>\r\n" . "    <td style='padding-right:0.5em'><em>" . $thisevent["id"] . "</em></td>\r\n" . "    <td style='padding-right:0.5em'>" . $thisevent["eventtype"] . "</td>\r\n" . "    <td style='padding-right:0.5em'>" . $period . "</td>\r\n" . ($onlyEditCurrentAndFuture ? "" : "    <td style='padding-right:0.5em' class='bold'>" . "<a href='" . $_SERVER["PHP_SELF"] . "?c=" . urlencode($thisevent["id"]) . "&amp;e=1'>[Edit]</a></td>\r\n") . "    <td style='padding-right:0.5em' class='bold'><a href='" . $_SERVER["PHP_SELF"] . "?c=" . urlencode($thisevent["id"]) . "&amp;u=1'>[Update]</a></td>\r\n" . ($onlyEditCurrentAndFuture ? "" : "    <td style='padding-right:0.5em' class='bold'>" . "[Delete]</td>\r\n") . "  </tr>\r\n";
             // Experimental: jQuery accordion
             $stdalt .= "    <tr>\r\n" . "      <td style='padding-right:0.5em'>" . $img . "</td>\r\n" . "      <td style='padding-right:0.5em' class='bold' title='" . $thisevent["subpath"] . "'>" . $title . "</td>\r\n" . "      <td style='padding-right:0.5em'><em>" . $thisevent["id"] . "</em></td>\r\n" . "      <td style='padding-right:0.5em'>" . $thisevent["eventtype"] . "</td>\r\n" . "      <td style='padding-right:0.5em'>" . $period . "</td>\r\n" . ($onlyEditCurrentAndFuture ? "" : "      <td style='padding-right:0.5em' class='bold'>" . "<a href='" . $_SERVER["PHP_SELF"] . "?c=" . urlencode($thisevent["id"]) . "&amp;e=1'>[Edit]</a></td>\r\n") . "      <td style='padding-right:0.5em' class='bold'><a href='" . $_SERVER["PHP_SELF"] . "?c=" . urlencode($thisevent["id"]) . "&amp;u=1'>[Update]</a></td>\r\n" . ($onlyEditCurrentAndFuture ? "" : "      <td style='padding-right:0.5em' class='bold'>" . "[Delete]</td>\r\n") . "    </tr>\r\n";
         }
         // end if
     }
     // end foreach
     $stdout .= "</table>\r\n";
     // Experimental: jQuery accordion
     $stdalt .= "  </table></div>\r\n" . "</div>\r\n";
     // --------------------------------
     // Experimental: jQuery accordion
     //     return $stdalt;
     return $stdout;
 }
开发者ID:,项目名称:,代码行数:81,代码来源:

示例6: parseAndExecuteSql

function parseAndExecuteSql($dbLink, $filename = "", $SQL = array())
{
    $res = array();
    mysqli_autocommit($dbLink, FALSE);
    if (!empty($filename) && preg_match("~.sql\$~", $filename)) {
        // (1) -- Process file with raw SQL data (used only for CREATE, not INSERT)
        ini_set("auto_detect_line_endings", true);
        // enables detecting '\r' line endings
        $handle = @fopen(INCLEVEL . PATH_SETUP_SQL . "/" . $filename, "r");
        if ($handle) {
            while (($sqlStmt = fgets($handle, 4096)) !== false) {
                $sqlStmt = preg_replace("~^--(.*)\$~", "", $sqlStmt);
                $sqlStmt = preg_replace("~^/\\*!(.*)\$~", "", $sqlStmt);
                $sqlStmt = trim($sqlStmt);
                $sqlStmt = preg_replace("~;\$~", "", $sqlStmt);
                if (empty($sqlStmt)) {
                    continue;
                }
                if (mysqli_query($dbLink, $sqlStmt)) {
                    $res[] = array("sql" => functions::truncateStringByWord($sqlStmt), "res" => 1);
                } else {
                    $res[] = array("sql" => functions::truncateStringByWord($sqlStmt), "res" => 0, "err" => mysqli_error($dbLink), "all" => $sqlStmt);
                }
            }
            fclose($handle);
        }
        return $res;
    } else {
        // (2) -- Obtain file with definition of PHP array $SQL
        if (!empty($filename) && preg_match("~.php\$~", $filename)) {
            if (file_exists(INCLEVEL . PATH_SETUP_SQL . "/" . $filename)) {
                include INCLEVEL . PATH_SETUP_SQL . "/" . $filename;
                if ($GLOBALS["dbFoundError"]) {
                    return array();
                }
            }
        }
        // (3) -- Process PHP array $SQL from input parameter or from file included in (2)
        if (!empty($SQL) && is_array($SQL)) {
            foreach ($SQL as $sqlStmt) {
                $sqlStmt = trim($sqlStmt);
                if (empty($sqlStmt)) {
                    continue;
                }
                if (mysqli_query($dbLink, $sqlStmt)) {
                    $res[] = array("sql" => truncateStringByWord($sqlStmt), "res" => 1);
                } else {
                    $GLOBALS["dbFoundError"] .= "<p><strong>&#187;</strong> " . "Could not execute SQL command &nbsp;'<strong>" . $sqlStmt . "</strong>'" . "</p>";
                    $res[] = array("sql" => truncateStringByWord($sqlStmt), "res" => 0, "err" => mysqli_error($dbLink), "all" => $sqlStmt);
                }
            }
        }
    }
    // end if
    // NB. Transaction rollbacks don't work for CREATE, DROP, DELETE
    if ($GLOBALS["dbFoundError"]) {
        mysqli_rollback($dbLink);
    } elseif (!mysqli_commit($dbLink)) {
        $GLOBALS["dbFoundError"] .= ERRORMESSAGE_SORRY_NO_COMMIT;
    }
    mysqli_autocommit($dbLink, TRUE);
    return $res;
}
开发者ID:,项目名称:,代码行数:63,代码来源:

示例7: outputRoomsEditorList

 public static function outputRoomsEditorList()
 {
     $stdout = $update = "";
     $allevents = $unallocatedevents = array();
     // --------------------------------
     // -- Obtain data
     // --------------------------------
     $allConfids = false;
     //TODO:
     /*
         $allConfids = functions::callMethod('fromdb_nwevents','fromdb/nwevents','getAgendaConferenceIdsForNorditaEvents','','1');
     */
     if (!is_array($allConfids) || empty($allConfids)) {
         return BLURB_SORRY_NO_EVENTS;
     }
     //TODO: use exception instead
     foreach ($allConfids as $confId) {
         $event = false;
         //TODO:
         /*
               $event = functions::callMethod('fromdb_nwevents','fromdb/nwevents','getOneEvent',$confId,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE);
         */
         if (!empty($event)) {
             if (!empty($event["from"]) && substr($event["startdate"], -5) != "01-01") {
                 $allevents[$event["from"]] = $event;
             } elseif (!empty($event["id"])) {
                 $event["from"] = 0;
                 $unallocatedevents[$event["id"]] = $event;
             }
         }
     }
     // end foreach
     krsort($allevents);
     krsort($unallocatedevents);
     $allevents = array_merge($unallocatedevents, $allevents);
     // --------------------------------
     // -- Output data
     // --------------------------------
     $stdout .= "  <p class='largefont'><strong>Select Event to be Edited Below</strong> &nbsp; or &nbsp; " . "<strong><a href='" . $_SERVER["PHP_SELF"] . "?menulookup=1'>Recreate 'menulookup' cache</a></strong></p>\r\n" . "  <p style='margin-bottom:2em'><strong>[Edit]</strong> = edit manually kept fields in nw_events DB;<br><strong>[Update]</strong> = update Agenda fields in nw_events DB from Agenda DB;<br><strong>[Delete]</strong> = delete record from nw_events DB</p>\r\n";
     $stdout .= "<table style='border-top:2px solid black;border-bottom:2px solid black'>\r\n";
     $currentyear = "";
     foreach ($allevents as $thisevent) {
         if ($thisevent["from"]) {
             $year = date("Y", $thisevent["from"]);
             if ($year != $currentyear) {
                 $currentyear = $year;
                 $stdout .= "  <tr>\r\n" . "    <th colspan='7' style='border:1px solid black;padding:0.2em 1em;background-color:#eee'>" . $currentyear . "</th>\r\n" . "  </tr>\r\n";
             }
             $period = functions::readableDateInterval($thisevent["start"], $thisevent["end"], TRUE);
             $update = "<a href='" . $_SERVER["PHP_SELF"] . "?c=" . urlencode($thisevent["id"]) . "&u=1'>[Update]</a>";
         } else {
             $period = "(<em>Dates missing</em>)";
             $update = "";
         }
         $title = functions::truncateStringByWord($thisevent["title"], 50);
         if ($thisevent["title"] != $title) {
             $title .= "...";
         }
         $img = !empty($thisevent["subpath"]) && file_exists(INCLEVEL . PATH_EVENTLOGOS . "/" . $thisevent["subpath"] . ".png") ? "<img src='" . PATH_EVENTLOGOS . "/" . $thisevent["subpath"] . ".png' alt='' style='width:10px;height:10px;border:1px solid black'>" : "";
         $stdout .= "  <tr>\r\n" . "    <td style='padding-right:0.5em'>" . $img . "</td>\r\n" . "    <td style='padding-right:0.5em' class='bold' title='" . $thisevent["subpath"] . "'>" . $title . "</td>\r\n" . "    <td style='padding-right:0.5em'>" . $thisevent["eventtype"] . "</td>\r\n" . "    <td style='padding-right:0.5em'>" . $period . "</td>\r\n" . "    <td style='padding-right:0.5em' class='bold'>" . "<a href='" . $_SERVER["PHP_SELF"] . "?c=" . urlencode($thisevent["id"]) . "&e=1'>[Edit]</a></td>\r\n" . "    <td style='padding-right:0.5em' class='bold'>" . $update . "</td>\r\n" . "    <td style='padding-right:0.5em' class='bold'>" . "[Delete]</td>\r\n" . "  </tr>\r\n";
     }
     $stdout .= "</table>\r\n";
     // --------------------------------
     return $stdout;
 }
开发者ID:,项目名称:,代码行数:65,代码来源:


注:本文中的functions::truncateStringByWord方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。