Example #1
0
 /**
  * Insert a new image.
  * @param int $uid
  * @param string $url
  * @param string $description
  * @return Dog_Link
  */
 public static function insertImage($uid, $url, $content)
 {
     $link = new self(array('link_id' => '0', 'link_uid' => $uid, 'link_url' => $url, 'link_text' => Common::substrFrom($url, '/', 'IMAGE', true), 'link_rating' => '0', 'link_date' => GWF_Time::getDate(14), 'link_type' => 'image'));
     if (false === $link->insert()) {
         echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         return false;
     }
     $path = GWF_WWW_PATH . 'dbimg/dogimg/' . $link->getID();
     if (false === GWF_File::writeFile($path, $content)) {
         echo GWF_HTML::err('ERR_WRITE_FILE', array($path));
         $link->delete();
         return false;
     }
     return $link;
 }
Example #2
0
 private static function createItemLangFile()
 {
     // 		printf("%s\n", __METHOD__);
     $langfile = Shadowlang::getItemfile();
     $items = SR_Item::getAllItems();
     usort($items, array('SR_Item', 'sort_type_asc'));
     $old_type = '';
     // 		printf("%s: sorted items...\n", __METHOD__);
     foreach (Dog_Lang::getISOCodes() as $iso) {
         $path = sprintf('%slang/item/shadowitems_%s.php', Shadowrun4::getShadowDir(), $iso);
         if (false === Common::isFile($path)) {
             continue;
         }
         $out = '<?php' . PHP_EOL;
         $out .= '$lang = array(' . PHP_EOL;
         foreach ($items as $item) {
             $item instanceof SR_Item;
             $type = $item->getItemType();
             if ($old_type !== $type) {
                 // 					printf("%s: New subsection %s\n", __METHOD__, $type);
                 $old_type = $type;
                 $out .= PHP_EOL;
                 $out .= '# ' . $type . PHP_EOL;
             }
             $key = $item->getName();
             if ($key === ($trans = $langfile->langISO($iso, $key))) {
                 // 					printf("%s: Unknown Key %s\n", __METHOD__, $key);
                 $out .= sprintf("'%s' => '%s',", $key, str_replace("'", '\\\'', $trans));
             } else {
                 // 					printf("%s: Old Key %s\n", __METHOD__, $key);
                 $out .= sprintf("'%s' => '%s',", $key, str_replace("'", '\\\'', $trans));
             }
             $out .= PHP_EOL;
             $key .= '__desc__';
             if ($key === ($trans = $langfile->langISO($iso, $key))) {
                 $out .= sprintf("'%s' => '%s',", $key, str_replace("'", '\\\'', $item->getItemDescription()));
             } else {
                 $out .= sprintf("'%s' => '%s',", $key, str_replace("'", '\\\'', $trans));
             }
             $out .= PHP_EOL;
         }
         $out .= ');' . PHP_EOL;
         $out .= '?>' . PHP_EOL;
         GWF_File::writeFile($path, $out);
     }
     return true;
 }