コード例 #1
0
function ckr_if_image_count($atts, $thing)
{
    // Extract attributes from tag
    extract(lAtts(array('category' => false, 'min' => false, 'max' => false, 'equal' => false, 'not' => false), $atts));
    // Count the images in specified category if given or globally
    $count = $category ? intval(ckr_image_count(array('category' => $category))) : intval(ckr_image_count());
    // Instead of almost unreadable if-else syntax, we use this clever switch-true/case-if counstruct
    switch (true) {
        case $min && !$max && !$equal && !$not:
            // Is greater than min value
            return parse(EvalElse($thing, $count >= intval($min) ? true : false));
            break;
        case $max && !$min && !$equal && !$not:
            // Is lesser than max value
            return parse(EvalElse($thing, $count <= intval($max) ? true : false));
            break;
        case $equal && !$min && !$max && !$not:
            // Is equal
            return parse(EvalElse($thing, $count == intval($equal) ? true : false));
            break;
        case $not && !$min && !$max && !$equal:
            // Is not equal
            return parse(EvalElse($thing, $count != intval($not) ? true : false));
            break;
        case $min && $max && !$equal && !$not:
            // Between min and max
            return parse(EvalElse($thing, $count >= intval($min) && $count <= intval($max) ? true : false));
            break;
        default:
            // Anything else will output an error message
            return '<!-- ckr_if_image_count: Wrong attribute count or combination. -->';
    }
}
コード例 #2
0
ファイル: Partial.php プロジェクト: bgarrels/textpattern
 /**
  * Conditional for yield.
  *
  * @param  array  $atts
  * @param  string $thing
  * @return string
  */
 public static function renderIfYield($atts, $thing)
 {
     global $yield;
     extract(lAtts(array('value' => null), $atts));
     $inner = end($yield);
     return parse(EvalElse($thing, $inner !== null && ($value === null || (string) $inner === (string) $value)));
 }
コード例 #3
0
function oui_if_dailymotion($atts, $thing)
{
    global $thisarticle;
    extract(lAtts(array('custom' => null, 'video' => null), $atts));
    $result = $video ? _oui_dailymotion($video) : _oui_dailymotion($thisarticle[strtolower($custom)]);
    return defined('PREF_PLUGIN') ? parse($thing, $result) : parse(EvalElse($thing, $result));
}
コード例 #4
0
ファイル: count.php プロジェクト: jmdeldin/jmd_count
/**
 * Evaluate counting results.
 *
 * @param array $atts
 * @property string $atts['eval'] Valid PHP comparison operator.
 * @property string $atts['table'] MySQL table name.
 * @property string $atts['where'] MySQL WHERE clause.
 */
function jmd_if_count($atts, $thing)
{
    extract(lAtts(array('eval' => '', 'table' => '', 'where' => ''), $atts));
    global $jmd_count_value;
    $jmd_count_value = jmd_count(array('table' => $table, 'where' => $where));
    $condition = eval("return({$jmd_count_value} {$eval});");
    $out = EvalElse($thing, $condition);
    return parse($out);
}
コード例 #5
0
ファイル: File.php プロジェクト: ClaireBrione/textpattern
 /**
  * Checks if the file is the last in the list.
  *
  * @param  array  $atts
  * @param  string $thing
  * @return string
  */
 public static function renderIfLastFile($atts, $thing)
 {
     global $thisfile;
     assert_file();
     return parse(EvalElse($thing, !empty($thisfile['is_last'])));
 }
コード例 #6
0
ファイル: jmd_rate.php プロジェクト: jmdeldin/jmd_rate
function if_jmd_rate_voted($atts, $thing)
{
    $condition = $GLOBALS['jmd_rate_instance']->voted;
    $out = EvalElse($thing, $condition);
    return parse($out);
}
コード例 #7
0
ファイル: taghandlers.php プロジェクト: bgarrels/textpattern
function if_custom_field($atts, $thing)
{
    global $thisarticle, $prefs;
    extract(lAtts(array('name' => @$prefs['custom_1_set'], 'val' => NULL), $atts));
    if ($val !== NULL) {
        $cond = @$thisarticle[$name] == $val;
    } else {
        $cond = !empty($thisarticle[$name]);
    }
    return parse(EvalElse($thing, $cond));
}
コード例 #8
0
ファイル: taghandlers.php プロジェクト: bgarrels/textpattern
function if_variable($atts, $thing = NULL)
{
    global $variable;
    extract(lAtts(array('name' => '', 'value' => ''), $atts));
    if (empty($name)) {
        trigger_error(gTxt('variable_name_empty'));
        return;
    }
    if (isset($variable[$name])) {
        if (!isset($atts['value'])) {
            $x = true;
        } else {
            $x = $variable[$name] == $value;
        }
    } else {
        $x = false;
    }
    return parse(EvalElse($thing, $x));
}
コード例 #9
0
function zem_if_alice($atts, $thing)
{
    extract(lAtts(array('name' => 'Bob'), $atts));
    return parse(EvalElse($thing, $name == 'Alice'));
}
コード例 #10
0
ファイル: l10n.php プロジェクト: netcarver/mlp_pack
 function l10n_if_lang($atts, $thing)
 {
     /*
     Basic markup tag. Use this to wrap blocks of content you only want to appear
     when the specified language is set or if the direction of the selected language matches
     what you want. (Output different css files for rtl layouts for example).
     */
     global $l10n_language;
     $out = '';
     if (!$l10n_language) {
         return $out;
     }
     extract(lAtts(array('lang' => $l10n_language['short'], 'dir' => '', 'wraptag' => ''), $atts));
     if (!empty($dir) and in_array($dir, array('rtl', 'ltr'))) {
         #	Does the direction of the currently selected site language match that requested?
         #	If so, parse the contained content.
         $cond = $dir == MLPLanguageHandler::get_lang_direction($l10n_language['short']);
         $out = parse(EvalElse($thing, $cond)) . n;
     } else {
         #	If the required language matches the site language, output a suitably marked up block of content.
         $cond = ($lang == $l10n_language['short'] or $lang == $l10n_language['long']);
         $out = parse(EvalElse($thing, $cond));
         if (!empty($wraptag)) {
             $dir = MLPLanguageHandler::get_lang_direction_markup($lang);
             $out = "<{$wraptag} lang=\"{$lang}\"{$dir}/>" . $out . "</{$wraptag}>" . n;
         }
     }
     return $out;
 }
コード例 #11
0
function sed_if_comments($atts, $thing)
{
    global $thisarticle, $pretext;
    $count = 0;
    if (!isset($thisarticle)) {
        $id = gAtt($atts, 'id', gps('id'));
        if (!$id && @$pretext['id']) {
            $id = $pretext['id'];
        }
        if (isset($id)) {
            $count = safe_field('comments_count', 'textpattern', "id={$id}");
        }
    } else {
        $count = $thisarticle['comments_count'];
    }
    return parse(EvalElse($thing, $count > 0));
}
コード例 #12
0
/**
 * Checks for neighbors.
 * 
 * @param array $atts
 * @param string $atts['type'] Type of neighbor to check for ('next'||'prev')
 */
function jmd_if_neighbor($atts, $thing)
{
    extract(lAtts(array('type' => ''), $atts));
    $condition = $GLOBALS['jmd_neighbor']->type == $type;
    $out = EvalElse($thing, $condition);
    return parse($out);
}
コード例 #13
0
ファイル: atb_if_form.php プロジェクト: atbradley/atb_if_form
function atb_output_form_if_exists($atts, $thing)
{
    global $yield;
    extract(lAtts(array('name' => ''), $atts));
    if (atb_form_exists($name)) {
        $yield[] = $thing !== null ? parse(EvalElse($thing, true)) : null;
        $outp = parse_form($name);
        array_pop($yield);
    } else {
        $outp = parse(EvalElse($thing, false));
    }
    return $outp;
}
コード例 #14
0
ファイル: sed_pcf.php プロジェクト: netcarver/sed_pcf
function sed_pcf_if_field_section($atts, $thing = '')
{
    #	Tests to see if there is a named section of the named custom field.
    global $thisarticle;
    extract(lAtts(array('custom' => '', 'section' => ''), $atts));
    $cond = false;
    $vars = @$thisarticle[$custom];
    if (!empty($vars) and !empty($section)) {
        $vars = sed_lib_extract_packed_variable_section($section, $vars);
        $cond = is_array($vars);
    }
    return parse(EvalElse($thing, $cond));
}
コード例 #15
0
ファイル: taghandlers.php プロジェクト: nope/Tipattern
function if_data($atts, $thing = NULL)
{
    $atts = lAtts(array('debug' => 0, 'ignore' => 0), $atts);
    $f = '/<txp:(\\S+)\\b(.*)(?:(?<!br )(\\/))?' . chr(62) . '(?(3)|(.+)<\\/txp:\\1>)/sU';
    $iftext = EvalElse($thing, true);
    $thresh = 1 + strlen(preg_replace($f, '', $iftext));
    $parsed = parse($iftext);
    if ($atts['ignore']) {
        $parsed = trim($parsed);
    }
    $parsed_len = strlen($parsed);
    $empty = 'Data';
    if (strlen($parsed) < $thresh) {
        #or !preg_match('/\S/', $parsed)) {
        $parsed = parse(EvalElse($thing, false));
        $empty = 'No Data';
    }
    return $atts['debug'] ? "<!-- {$empty} -- Threshhold: {$thresh} Length: {$parsed_len} -->" . $parsed : $parsed;
}
コード例 #16
0
ファイル: atb_twitter.php プロジェクト: atbradley/atb_twitter
function atb_tw_if_is_reply($atts, $thing)
{
    global $atb_thistweet;
    return parse(EvalElse($thing, $atb_thistweet->in_reply_to_status_id != ''));
}
コード例 #17
0
ファイル: taghandlers.php プロジェクト: bgarrels/textpattern
function if_last_article($atts, $thing)
{
    global $thisarticle;
    return parse(EvalElse($thing, !empty($thisarticle['is_last'])));
}
コード例 #18
0
function mem_profile($atts, $body = '')
{
    global $mem_profile, $txp_user, $ign_user;
    if (isset($ign_user)) {
        $txp_user = $ign_user;
    }
    extract(lAtts(array('user' => '', 'userid' => '', 'var' => 'RealName', 'form' => ''), $atts));
    if (empty($user) && empty($userid)) {
        // use the old method
        if (!is_array($mem_profile) && $txp_user) {
            $mem_profile = safe_row('*', mem_get_user_table_name(), "name = '" . doSlash($txp_user) . "'");
        }
    } else {
        $mem_profile = is_array($mem_profile) ? $mem_profile : array();
        // look up a potentially new user
        if (!empty($user)) {
            if (!array_key_exists('name', $mem_profile) || strcmp($mem_profile['name'], $user) != 0) {
                $mem_profile = safe_row('*', mem_get_user_table_name(), "name = '" . doSlash($user) . "'");
            }
        }
        if (!empty($userid) && is_numeric($userid)) {
            if (!array_key_exists('user_id', $mem_profile) || strcmp($mem_profile['user_id'], $userid) != 0) {
                $mem_profile = safe_row('*', mem_get_user_table_name(), "user_id = " . doSlash($userid));
            }
        }
    }
    $out = '';
    if (empty($form) && empty($body)) {
        if ($mem_profile) {
            $out = array_key_exists($var, $mem_profile) ? $mem_profile[$var] : '';
        }
    } else {
        $thing = empty($body) ? fetch_form($form) : $body;
        $out = parse(EvalElse($thing, !empty($mem_profile)));
    }
    return $out;
}
コード例 #19
0
 function sed_lib_home_or_section($atts, $thing)
 {
     extract(lAtts(array('sectlist' => ''), $atts, 0));
     global $pretext;
     $do_thing = $pretext['s'] == "default" && empty($pretext['c']) && empty($pretext['q']) && empty($pretext['pg']);
     if (!$do_thing && !empty($sectlist)) {
         $sectlist = do_list($sectlist);
         $do_thing = in_array($pretext['s'], $sectlist);
     }
     return parse(EvalElse($thing, $do_thing));
 }
コード例 #20
0
ファイル: taghandlers.php プロジェクト: bgarrels/textpattern
function if_plugin($atts, $thing)
{
    global $plugins, $plugins_ver;
    extract(lAtts(array('name' => '', 'ver' => ''), $atts));
    return parse(EvalElse($thing, @in_array($name, $plugins) and (!$ver or version_compare($plugins_ver[$name], $ver) >= 0)));
}
コード例 #21
0
ファイル: Link.php プロジェクト: bgarrels/textpattern
 /**
  * Checks if the link is the last in the list.
  *
  * @param  array  $atts
  * @param  string $thing
  * @return string
  */
 public static function renderIfLastLink($atts, $thing)
 {
     global $thislink;
     assert_link();
     return parse(EvalElse($thing, !empty($thislink['is_last'])));
 }
コード例 #22
0
 function gbp_if_text($atts, $thing)
 {
     global $pretext;
     extract(lAtts(array('name' => '', 'val' => ''), $atts));
     $match = false;
     if (!empty($name)) {
         if (empty($val)) {
             $match = isset($pretext["permlink_text_{$name}"]);
         } else {
             $match = @$pretext["permlink_text_{$name}"] == $val;
         }
     }
     return parse(EvalElse($thing, $match));
 }